Datatypes Operators Printing and User Input
Datatypes Operators Printing and User Input
2. Printing Variations
Sl Python Code Output
2.1 print (“Hello”+ “Hi”)
2.2 print (“Hello”+ “ ”+ “Hi”)
2.3 print (“Hello”, end= “”)
print (“Hi”)
2.4 print (“Hello”, Hi”)
2.5 print (“Hello”)
print (“Hi”)
2.6 print (“Hello”, “Hi”, end= 5)
print(“Yo”)
2.7 print (“Hi” + 5)
2.8 print (“Hi” + str(5))
2.9 x=5
print (6 + int(x))
2.10 print (“Hi” * 3)
Worksheet 1: Datatypes, Operators, Printing and User Input | CSE110 |
3. User Input
Sl Python Code Output
3.1 name = input (“Enter your name”)
print (type(name))
3.2 age = input (“Enter age”)
print (type(age))
3.3 cgpa = float ( input ( ) )
print(type(cgpa))
4. Coding Problems
4.1 Take the name, student id and CGPA of a student and print the information in the way shown in the
output.
Your Code Sample Input Sample Output
Afnan Name: Afnan
23301519 Student ID: 23301519
3.9 CGPA: 3.9
4.2 Take the first name, last name, age and CGPA of a student. Change the last name to “Rahman”. Subtract
2 from the age and add 0.25 with the CGPA. Finally print the information in the way shown in the
output.
Your Code Sample Input Sample Output
First Name: Labiba Name: Labiba Rahman
Last Name: Arif Age: 21
Age: 23 CGPA: 3.95
CGPA: 3.7