0% found this document useful (0 votes)
4 views

Variables Sheet 4

Uploaded by

235271
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Variables Sheet 4

Uploaded by

235271
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Problems

Prepared by

Eng: Badr Sayed


Software Engineer & Teaching Assistant at Faculty of
Artificial Intelligence - Egyptian Russian University
Sheet 4
Variables

Problems:
- Write a python program to convert the following statements.

a) C to integer value
b) 25 to float value
c) 195 to character value
d) A to integer value
e) 96.3 to character value
f) u to float value
g) 85.3 to boolean value
h) B to Boolean value
i) 99 to string value
j) + to integer value
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Problems:
- What is the output of the following statements?

a) Problem 1:
o x = 2
y = 5
z = 10
value = x * y + z ** x // z
print("Value of Equation = ", value)

b) Problem 2:
o x = 21
y = 50
z = 3
value = x % (y + z) ** x / z + y
print("Value of Equation = ", value)

c) Problem 3:
‫‪o x = 15‬‬
‫‪y = 7‬‬
‫‪z = 18‬‬
‫)‪value = x ** y + z * x // (z % x‬‬
‫)‪print("Value of Equation = ", value‬‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫‪Problems:‬‬
‫‪- Trace the following expressions.‬‬

‫‪a) 3 % 20‬‬
‫‪b) 5 % 4‬‬
‫‪c) 1 % 100‬‬
‫‪d) 56 % 60‬‬
‫‪e) 8 % 10‬‬
‫‪f) 78 % 98‬‬
‫‪g) 4 % 1000‬‬
‫‪h) 6 % 2‬‬
‫‪i) 4 % 10‬‬
‫‪j) 65 % 66‬‬
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
‫‪Problems:‬‬
‫‪- Trace and print the output of the following statements.‬‬

‫‪a) Problem 1:‬‬


‫‪o x = 10‬‬
‫‪y = 2‬‬
‫)‪print("Result = ", x & y‬‬

‫‪b) Problem 2:‬‬


‫‪o x = 8‬‬
‫‪y = 20‬‬
‫)‪print("Result = ", x ^ y‬‬

‫‪c) Problem 3:‬‬


‫‪o x = 17‬‬
‫‪y = 9‬‬
print("Result = ", x | y)

d) Problem 4:
o x = 21
y = 50
print("Result = ", x & y)

e) Problem 5:
o x = 5
y = 2
print("Result = ", x << y)

f) Problem 6:
o x = -10
y = 4
print("Result = ", x << y)

g) Problem 7:
o x = 10
y = 3
print("Result = ", x >> y)

h) Problem 8:
o x = -8
y = 1
print("Result = ", x >> y)

i) Problem 9:
o x = 8
print("Result = ", ~x)

j) Problem 10:
o x = 9
y = 13
z = x
print("The Result is = ", x is y)
print("The Result is = ", z is y)
print("The Result is = ", x is z)
print("The Result is = ", y is not z)
print("The Result is = ", x is not y)
print("The Result is = ", z is not x)

k) Problem 11:
o v1 = "Welcome Guys in Python Course"
v2 = " Python Course"
v3 = "h"
print("The Output is ", v1 in v2)
print("The Output is ", v3 in v2)
print("The Output is ", v1 in v3)
print("The Output is ", v2 in v3)
print("The Output is ", v1 not in v2)
print("The Output is ", v3 not in v1)
‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
https://www.facebook.com/BS.OfficialPage

https://www.youtube.com/c/BadrSayed11

[email protected]

You might also like