Python Questions - Revision
Python Questions - Revision
4. Shiv has written following code into python but he is not able to get the
correct output.
n=int(“Enter number”)
triple=n**3
Print(“Number three times:”,n)
Identify the syntax and logical errors and write the correct code. Underline
each correction.
5. Do as directed:
i. Assign 5 to a variable x.
ii. Write statement to compute the square of given number a.
6. What will be the output of the following?
a) print(“Bhavans\nNewsprint\nVidyalaya”)
b) print(“Bhavans\nNewsprint\tVidyalaya”)
c) print(“Bhavans”,Newsprint”,”Vidyalaya”,sep=”\n”)
d) print(“Bhavans”,Newsprint”,”Vidyalaya”,sep=”\t”)
e) print(“Bhavans”,Newsprint”,”Vidyalaya”,end=”lt”)
f) print(“Bhavans”,Newsprint”,”Vidyalaya”,end=”!”)
7. What is the default value of Sep and end?
8. Predict output
if 4 + 5 == 10:
print("TRUE")
else:
print("FALSE")
print("TRUE")
9. Predict output
x=5
if (x > 2):
x=x*2
if (x > 4):
x=0
print(x)
10. Predict output
x=5
if (x > 2):
x=x*2
elif (x > 4):
x=0
print(x)
11. Predict output
I. True and False
12. Program to accept salary of an employee and calculate the tax amount as
per the following conditions.
Salary > 70000 : 8% of salary
Salary > 60000 : 7% of salary
Salary > 50000 : 5% of salary
Else No tax