0% found this document useful (0 votes)
37 views2 pages

Datatypes Operators Printing and User Input

This document contains examples of Python code demonstrating data types, operators, printing, and user input. It includes code samples and expected output for numeric calculations, string operations, logical operators, variable assignment, input and type conversion.

Uploaded by

Kazi Tasmia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Datatypes Operators Printing and User Input

This document contains examples of Python code demonstrating data types, operators, printing, and user input. It includes code samples and expected output for numeric calculations, string operations, logical operators, variable assignment, input and type conversion.

Uploaded by

Kazi Tasmia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Worksheet 1: Datatypes, Operators, Printing and User Input | CSE110 |

1. Datatype Conversion and Operator Precedence Basics


Sl Python Code Output Sl Python Code Output
1.1 print (“Hello”) 1.2 print (4+5.5)
1.3 x, y = 6, 10 1.4 print (x - y)
1.5 print (x + y) 1.6 print (x * y)
1.7 print (x**2) 1.8 print (y ** x)
1.9 print (y / 3) 1.10 print (x % y)
1.11 print (y // 3) 1.12 print (y % x)
1.13 print (y % y) 1.14 print (y / y)
1.15 print (-5 / 2) 1.16 print (-5 // 2)
1.17 print (y > x) 1.18 print (x > y)
1.19 print (y == x) 1.20 print (y != x)
1.21 print (y >= x) 1.22 print (x <= y)
1.23 a = True 1.24 print (a)
b = False print (“b”)
1.25 print (a and b) 1.26 print (a or b)
1.27 print (a and not b) 1.28 print (not a)
1.29 y=x 1.30 print (x)
1.31 print (y) 1.32 x -= 2
1.33 x=x+2 1.34 x //= 1
1.35 print (x) 1.36 print (x != y and a)
1.37 print ( x*y**2) 1.38 print (x+5*4%2-1)
1.39 print (x == y*2//2 - 1.40 print (x – ((x+y%2)
2**(2-1)) *3)//2)

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

You might also like