You are on page 1of 34

RATHNAVEL SUBRAMANIAM COLLEGE OF ARTS AND SCIENCE

Sulur, Coimbatore – 641 402

Name :

Register Number :

Class : III BCA

Subject :
RATHNAVEL SUBRAMANIAM COLLEGE OF ARTS AND SCIENCE
Sulur, Coimbatore – 641 402
REGISTER NUMBER

Certified that this is a bonafide record of .....................................

.............................................................. Practical work done by

Mr./Ms ........................................................................ pursuing

.............................................. in I / II / III / IV / V / VI semester

during the academic year 2023 - 2024.

Faculty HoD

Submitted for the Practical Examination held at Rathnavel


Subramaniam (RVS) College of Arts and Science on
................
Examiners:

Internal…………………………..….

External………………….……….…
Pr. No. DATE CONTENT Pg. No. SIGNATURE
Pr. No. DATE CONTENT Pg. No. SIGNATURE
EX.NO:01(1)
DATE:
CREATE FOUR VARIABLES

AIM:
Write a python Program creating four variables, assigning values and
testing assigned values type.

ALGORITHM:
Step 1: Create a four variable.
Step 2: Assign the values for variables.
Step 3: print the type of the value.

CODE:
my_integer = 10 # set value 10 to variable my_integer
my_decimal = 99.9 # set value 99.9 to variable my_decimal
my_string = "Python" # set value Python to variable my_string
my_boolean = True # set value True to variable my_boolean
print(type(my_integer))
print(type(my_decimal))
print(type(my_string))
print(type(my_boolean))
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:01(2)
DATE:
PRINT FOUR VARIABLES

AIM:
Write a python Program for printing given four variables data types.

ALGORITHM:
Step 1: Import the date and time package.
Step 2: import random module.
Step 3: Create a four variable.
Step 4: Assign the values for variables.
Step 5: print the type of the value.

CODE:
from datetime import date
import random
a = "Hello, world!"
b = date.today()
c = random.randint(0,100)
d = random
print(type(a)) #finding & printing data type of a variable named a
print(type(b)) #finding & printing data type of a variable named b
print(type(c)) #finding & printing data type of a variable named c
print(type(d)) #finding & printing data type of a variable named d
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:02(1)
DATE:
CONVERTING TO STRING

AIM:
Write a python Program for converting given four variables data types to
string type

ALGORITHM:
Step 1: Import the date and time package.
Step 2: Create a four variable.
Step 3: Assign the values for variables.
Step 4: store the value as a string in new variable.
Step 5: print the type of the value and values.

CODE:
from datetime import date
new_integer = 8
new_float = 8.2
new_date = date.today()
new_boolean = False
integer_as_string = str(new_integer) # converting integer to string
float_as_string = str(new_float) # converting float to string
date_as_string = str(new_date) # converting date to string
boolean_as_string = str(new_boolean) # converting boolean to string
print(integer_as_string, type(integer_as_string))
print(float_as_string, type(float_as_string))
print(date_as_string, type(date_as_string))
print(boolean_as_string, type(boolean_as_string))
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:02(2)
DATE:
CONVERT FROM STRINGS

AIM:
Write a python Program for converting three string variables to other data
types.

ALGORITHM:
Step 1: Create a three variable.
Step 2: Assign the values are string type.
Step 3: store the value as other data types.
Step 4: print the type of the value.

CODE:
a = "5.1"
b = "Hello!"
c = "5"
as_integer = int(c) #convert string to integer
as_float = float(a) #convert string to float
as_boolean = bool(b) #convert string to boolean
print(as_integer, type(as_integer))
print(as_float, type(as_float))
print(as_boolean, type(as_boolean))
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:03(1)
DATE:
SIX VARIABLE COMPARISONS

AIM:
Write a python Program for comparing given six variables are equal or
not

ALGORITHM:
Step 1: Import the date and time package.
Step 2: Create two strings, two dates and two times variable.
Step 3: Assign the values for variables.
Step 4: Compare the two corresponding string, dates, and times.
Step 5: print the output of comparison.
CODE:
from datetime import time
from datetime import date
mystery_string_1 = "Hello, world"
mystery_string_2 = "Hello, world"
mystery_date_1 = date(2019, 1, 15)
mystery_date_2 = date(2019, 1, 15)
mystery_time_1 = time(12, 45)
mystery_time_2 = time(12, 45)
print(mystery_string_1 == mystery_string_2) #compare two strings and
print result
print(mystery_date_1 == mystery_date_2) #compare two dates and print
result
print(mystery_time_1 == mystery_time_2) #compare two times and print
result
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:03(2)
DATE:
GO OUT TO LUNCH

AIM:
Write a python Program whether you can go out to lunch or not based on
different constraints.

ALGORITHM:
Step 1: Create a three variable.
Step 2: Assign the values are Boolean type.
Step 3: print the output of the Boolean value using logical gates.

CODE:
hungry = True
coworkers_going = False
brought_lunch = False # checking hungry with other condition
print(hungry and (coworkers_going or not brought_lunch))
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:04(1)
DATE:
FIVE MATH FUNCTIONS

AIM:
Develops python Program for five math functions.

ALGORITHM:
Step 1: Create a two variable.
Step 2: Assign the values for variables.
Step 3: print the output of the variables math function (+,-,*, /, %).

CODE:
mystery_value_1 = 6
mystery_value_2 = 2
print(mystery_value_1 + mystery_value_2) # calculate addition and print
result
print(mystery_value_1 - mystery_value_2) # calculate subtraction and
print result
print(mystery_value_1 * mystery_value_2) # calculate multiplication and
print result
print(mystery_value_1 / mystery_value_2) # calculate divide and print
result
print(mystery_value_1 % mystery_value_2) # calculate modulus and
print result
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:04(2)
DATE:
EVERY THIRD

AIM:
Write a python Program to print every third value using for loop

ALGORITHM:
Step 1: Create a variable and assign the value.
Step 2: use the for loop and range function.
Step 3: set the incremental value as three.
Step 4: the for loop prints the every third Number between the range.

CODE:
mystery_int = 50
#test input value # loop starts from 1 and extends upto mystery_int and
step value is 3
For loopCounter in range(1,mystery_int+1,3):
print(loopCounter) # print each loopCounter value
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:05
DATE:
TIP TAX CALCULATOR

AIM:
Develop a python Program to print the tip, tax amount and calculate it.

ALGORITHM:
Step 1: Declare meal cost, tip_rate, tax_rate.
Step 2: Calculate tip and tax amount by multiplying meal cost.
Step 3: Print the subtotal, Tax amount, tip amount, total amount.

CODE:
meal_cost = 10.00
tax_rate = 0.08
tip_rate = 0.20
taxAmount = tax_rate * meal_cost #calculate taxAmount
tipAmount = tip_rate * meal_cost #calculate tipAmount
totalAmount = meal_cost + taxAmount + tipAmount #calculate
totalAmount
print("Subtotal:"+str(meal_cost)) # print subtotal
print("Tax:"+str(taxAmount)) # print tax amount
print("Tip:"+str(tipAmount)) # print tip amount
print("Total:"+str(totalAmount)) # print total
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:6
DATE:
FREEZING

AIM:
Develop a python Program for find temperature is freezing or not

ALGORITHM:
Step 1: Declare temperature and Celsius.
Step 2: use two conditions that temperature less than or equal to 32 and
Celsius is true or less than 0 Celsius or false.
Step 3: Print temperature is freezing or not freezing.

CODE:
temperature = -3.7 #test input value
celsius = True #test input value # checking with two conditions
if(temperature <= 0 and celsius) or (temperature <= 32 and celsius ==
False):
print("Freezing") #print if condition is true
else:
print("Not freezing") #print if condition is not true
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:7
DATE:
RETURN DATE

AIM:
Develop a python Program for returns to todaysdate

ALGORITHM:
Step 1: Important date from datetime package.
Step 2: In a function declare todaysdate and convert into date string return
the string variable.
Step 3: Call the function using function.
Step 4: It will print the today date.

CODE:
from datetime import date
def get_todays_date(): # function starts
todays_date = date.today() # assign date value as given format year
/ month / day
datestring = str(todays_date.year) +"/"+ str(todays_date.month)
+"/"+str(todays_date.day)
return datestring #function returns
print(get_todays_date()) #invoking a function
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:8(1)
DATE:
HIDE AND SEEK

AIM:
Develop a python Program that creates a function called hide_and_seek

ALGORITHM:
Step 1: Define the function for his and seek.
Step 2: Use for loop to count the number.
Step 3: Print the message.
Step 4: Call the function.

CODE:
def hide_and_seek():
for loopCounter in range(1,11):
print(loopCounter)
print("Ready or not, here I come!")
hide_and_seek( ) #Invoking function
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:08(2)
DATE:
STRING LENGTH TUPLES

AIM:
Develop a python Program find a string length and print it as string length
tuples

ALGORITHM:
Step 1: Define the function which return string length.
Step 2: Invoke the string length function with various string.
Step 3: The function return the string and string length as tuples.

CODE:
def string_length(string):
length = len(string)
return (string,length)
print(string_length("Hello, world!"))
print(string_length("CS1301"))
print(string_length("Some people pronounce it 'toople'. Others pronounce
it 'tuhple'. Either is correct."))
OUTPUT:

RESULT:
This program is executed and output verified.
EX.NO:09
DATE:
STEPS

AIM:
Develop a python Program that creates step() function

ALGORITHM:
Step 1: Define the function which return the values print as steps.
Step 2: Use for loop to count the numbers.
Step 3: Using the while loop to end the loop in the last number.
Step 4: Return the value and print as steps.

CODE:
def steps(value):
output=""
for loopCounter in range(1,value+1):#outer loop starts from here
output += (str(loopCounter) +str(loopCounter) +
str(loopCounter) +"\n")
while loopCounter>0:#inner loop starts from here
output +="\t"
loopCounter= loopCounter-1 #inner loop ends here
return output #outer loop ends here
print(steps(3)) #calling function with a parameter 3
print(steps(6)) #calling function with a parameter 6
OUTPUT:

RESULT:
This program is executed and output verified.
Ex.No:10
Date:
CREATING INSTANCE

AIM:
Develop a python Program that creates instances to the following class
named students

ALGORITHM:
Step 1: Create a class and define the function.
Step 2: Create a variables with the self-parameter.
Step 3: Create object for the class to call.
Step 4: Assign the value for the object to call the function.
Step 5: Print the value using the call method.

CODE:
class Student:
def init (self):
self.studentName = ""
self.GPA = 0.0
self.creditHours = 0
self.enrolled = True
self.classes = []
newStudent = Student #create a variable called newStudent of type
Student
newStudent.enrolled=True #set the value of enrolled for newStudent to
the boolean True
newStudent.GPA=3.9 #set the value of GPA for newStudent to the float
3.9 #set the value of creditHours for newStudent to the integer 1334
newStudent.creditHours=1334 #set the value of classes for newStudent to
the list ["CS1301", "PHYS3001", "ISYE3029"]:
newStudent.classes=["CS1301", "PHYS3001", "ISYE3029"]
newStudent. studentName = "George P. Burdell" # print all values using
newStudent variable
print(newStudent. studentName)
print(newStudent.enrolled)
print(newStudent.GPA)
print(newStudent.creditHours)
print(newStudent.classes)

OUTPUT:

RESULT:
This program is executed and output verified.

You might also like