My Report

Python Programming Practice Test 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of the following results in a SyntaxError?

2. What will be the output of the python code shown below for various styles of format specifiers?

x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res

3. Which of the following cannot be a variable?

4. What will be the output of the following Python code snippet?

x=3.3456789
'%s' %x, str(x)

5. Which of the following expressions results in an error?

6. What will be the output of the following Python expression if x=56.236?

print("%.2f"%x)

7. It is not possible for the two’s complement value to be equal to the original value in any case.

8. The expression shown below results in an error.

print("-%5d0",989)

9. What will be the output of the following Python code snippet?

a='hello'
q=10
vars()

10. What will be the output of the following Python code snippet?

x=3.3456789
'%f | %e | %g' %(x, x, x)

 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.