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

python test1

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

python test1

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

Python Test Paper

Total Time : 1:00 Hour Total : 50 Marks

1. Who developed Python Programming Language?

a) Wick van Rossum b) Rasmus Lerdorf c) Guido van Rossum d) Niene Stom

2. Which type of Programming does Python support?

a) object-oriented programming c) functional programming

b) structured programming d) all of the mentioned

3. Is Python case sensitive when dealing with identifiers?

a) no b) yes c) machine dependent d) none of the mentioned

4. Which of the following is the correct extension of the Python file?

a) .python b) .pl c) .py d) .p

5. Is Python code compiled or interpreted?

a) Python code is both compiled and interpreted c) Python code is only compiled

b) Python code is neither compiled nor interpreted d) Python code is only interpreted

6. All keywords in Python are in _________

a) Capitalized c) UPPER CASE

b) lower case d) None of the mentioned

7. What will be the value of the following Python expression? 4+3%5

a) 7 b) 2 c) 4 d) 1

8. Which of the following is used to define a block of code in Python language?

a) Indentation b) Key c) Brackets d) All of the mentioned

9. Which keyword is used for function in Python language?

a) Function b) def c) Fun d) Define

10. Which of the following character is used to give single-line comments in Python?

a) // b) # c) ! d) /*

11. What will be the output of the following Python code?

i=1
while True:
if i%3 == 0:
break
print(i)
a) 1 2 3i + = 1 c) 1 2 d) none of the
mentioned
b) error
12. What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

13. What will be the output of the following Python code snippet if x=1?

x<<2

a) 4 b) 2 c) 1 d) 8

14. Which of the following is true for variable names in Python?


a) underscore and ampersand are the only two special characters allowed
b) unlimited length
c) all private members must have leading and trailing underscores
d) none of the mentioned

15. What are the values of the following Python expressions?

2**(3**2)
(2**3)**2
2**3**2
a) 512, 64, 512 c) 64, 512, 64
b) 512, 512, 512 d) 64, 64, 64

16. Which of the following is the truncation division operator in Python?


a) | b) // c) / d) %

17. Which of the following is not a core data type in Python programming?
a) Tuples b) Lists c) Class d) Dictionary

18. What will be the output of the following Python statement?

1. >>>"a"+"bc"

a) bc b) abc c) a d) bca

19. What arithmetic operators cannot be used with strings in Python?


a) * b) – c) + d) All of the
mentioned

20. Which of the following statements is used to create an empty set in Python?
a) ( ) b) [ ] c) { } d) set()

21. What is the maximum possible length of an identifier in Python?


a) 79 characters c) 63 characters
b) 31 characters d) none of the mentioned
22. What will be the output of the following Python program?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)

a) error b) 0 1 2 0 c) 012 d) none of the


mentioned
23. bin(29)
a) ‘0b10111’ b) ‘0b11101’ c) ‘0b11111’ d) ‘0b11011’

24. What will be the output of the following Python expression if x=15 and y=12?

x & y

a) b1101 c) 12
b) 0b1101 d) 1101
25. What will be the output of the following Python code?

i = 1
while True:
if i%0O7 == 0:
break
print(i)
i += 1

a) 1 2 3 4 5 6 c) error
b) 1 2 3 4 5 6 7 d) none of the mentioned

Descriptive type question:


1.Write a program to find if the given number is prime or not.
2.Write a program to check if the given number is palindrome or not.

3. Write a program to print the following pattern.

4.Python Program for Sum of squares of first n natural numbers


Given a positive integer N. The task is to find 12 + 22 + 32 + ….. + N2.
Examples:
Input : N = 4
Output : 30
12 + 22 + 32 + 42
= 1 + 4 + 9 + 16
= 30

You might also like