0% found this document useful (0 votes)
14 views12 pages

Quiz1 Paper

The document contains a quiz with multiple choice questions about Python programming concepts like data types, operators, loops, functions, and debugging. It tests understanding of syntax, program flow and output for various code snippets.

Uploaded by

Yogesh Garg
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)
14 views12 pages

Quiz1 Paper

The document contains a quiz with multiple choice questions about Python programming concepts like data types, operators, loops, functions, and debugging. It tests understanding of syntax, program flow and output for various code snippets.

Uploaded by

Yogesh Garg
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/ 12

PSP (ITFC-0101) Quiz 1 (Set A) Date: Oct 18, 2023 MM: 20

Name: Roll Number:


Batch: Branch:
1. Find out an invalid data type in Python? 2. Explain the difference between "while" and "for"
a. int loops in Python.
b. decimal a. "While" is used for indefinite iteration, and "for" is used
c. string for definite iteration
d. list b. "While" is used for definite iteration, and "for" is used for
indefinite iteration
c. They are synonyms and can be used interchangeably
d. "While" is used when number of iterations known, and
"for" is used when number of iterations unknown
3. Compute the output of program: 4. Which of the following operator has its associativity
for i in range(0, 10, -1): from right to left:
print(i) a. +
a. This will print numbers from 1 to 9. b. //
b. This will print numbers from 0 to 9. c. %
c. This will print numbers from 9 to 0. d. **
d. Nothing will be printed.
5. What is computational thinking? 6. Which of these collection designs a Tuple:
a. Solving problems using computers a. (“apple”, “banana”, “Cherry”)
b. A problem-solving method that involves breaking b. {“name”:”apple”, “color”:”green”}
down a problem into smaller, manageable parts c. [“apple”, “banana”, “cherry”]
c. Programming without using a computer d. {“apple”, “banana”, “cherry”}
d. None of these
7. How to denote multiline comment in Python? 8. What is the value of expressions 8/4/2, 8/(4/2):
a. // Comment a. (1.0, 4.0)
b. /* Comment */ b. (1.0, 1.0)
c. # Comment c. (4.0. 1.0)
d. ''' Comment ''' d. (4.0, 4.0)
9. Output of following python expressions: 10. What is the role of debugging in Python
2**(3**2) programming?
(2**3)**2 a. Writing new code
2**3**2 b. Optimizing code for performance
a. 64, 512, 64 c. Identifying and fixing errors in code
b. 64, 64, 64 d. None of the above
c. 512, 512, 512
d. 512, 64, 512
11. What will be the output of the following code 12. What will be the output of the following program:
snippet? for i in range(5):
print(2**3 + (5 + 6)**(1 + 1)) print(i)
a. 129 else:
b. 28 print("done")
c. 121 a. Error because else cannot be used without if
d. 127 b. Error because else cannot be used without break
c. This will print numbers from 0 to 5 and a message “done”
after that.
d. This will print numbers from 0 to 4 and a message “done”
after that.
13. A box that can represent two different conditions. 14. Evaluate: 5793405 X 99999 and write answer
a. Rectangle
b. Diamond
c. Circle
d. Parallelogram
15. What is the result of executing the following code? 16. What is the output of the following program _______
number = 5 i=0
while number <= 5: while i < 3:
if number < 5: print (i)
number = number + 1 i += 1
print(number) else:
print (0)
a. The program will loop indefinitely a. 0 1 2 3 0
b. The value of number will be printed exactly 1 time b. 0 1 2
c. The while loop will never get executed c. 0 1 2 0
d. The value of number will be printed exactly 5 times d. 0 1 2 3
17. Output of the following program is _________ 18. Choose correct value to be printed by the following
a=5 code when it executes?
b=2 sum = 0
a=a+b values = [1,3,4,7]
b=a-b for number in values:
a=a-b sum = sum + number
print(a, b) print(sum)
a. 5, 2 a. 18
b. 2, 5 b. 15
c. 3, 2 c. 7
d. 2, 3 d. 0
19. Output of the following flow chart

a. 246
b. 357
c. 23456
d. 34567

20. What will be the output of the following python var1 = [3, 2, 5, 6, 0, 7, 9]
code? sum = 0
a. 8 18 sum1 = 0
b. 8 3 for elem in var1:
c. 8 12 if (elem%2 == 0):
d. 2 3 sum = sum +elem
continue
if (elem%3 == 0):
sum1 = sum1 + elem
print(sum, end = “ ”)
print(sum1)
Answers (SET A):
1. b
2. a
3. d
4. d
5. b
6. a) Assigning multiple values to a single variable.
7. d) ''' Comment '''
8. a
9. d
10. c) Identifying and fixing errors in code.
11. a
12. d
13. b
14. 579334706595
15. a
16. c
17. b
18. b
19. b
20. c
PSP (ITFC-0101) Quiz 1 (Set B) Date: Oct 18, 2023 MM:20
Name: Roll Number:
Batch: Branch:
1. What is computational thinking? 2. What will be the output of the following code snippet?
a. Solving problems using computers print(2**3 + (5 + 6)**(1 + 1))
b. A problem-solving method that involves breaking a. 121
down a problem into smaller, manageable parts b. 28
c. Programming without using a computer c. 129
d. None of these d. 127

3. How to denote multiline comment in Python? 4. What is the value of expressions 8/4/2, 8/(4/2):
a. ''' Comment ''' a. (1.0, 1.0)
b. /* Comment */ b. (4.0. 1.0)
c. # Comment c. (4.0, 4.0)
d. // Comment d. (1.0, 4.0)
5. Find out an invalid data type in Python? 6. Which of these collection designs a Tuple:
a. int a. {“name”:”apple”, “color”:”green”}
b. string b. (“apple”, “banana”, “Cherry”)
c. decimal c. [“apple”, “banana”, “cherry”]
d. list d. {“apple”, “banana”, “cherry”}
7. What is the output of the following program _____ 8. Output of following python expressions:
i=0 2**(3**2)
while i < 3: (2**3)**2
print i 2**3**2
i += 1 a. 64, 512, 64
else: b. 512, 64, 512
print 0 c. 512, 512, 512
a. 0 1 2 3 0 d. 64, 64, 64
b. 0 1 2 0
c. 0 1 2
d. 0 1 2 3
9. Output of the following flow chart

a. 2 4 6
b. 3 4 5 6 7
c. 2 3 4 5 6
d. 3 5 7

10. Which of the following operator has its 11. What is the role of debugging in Python
associativity from right to left: programming?
a. + a. Identifying and fixing errors in code
b. // b. Optimizing code for performance
c. ** c. Writing new code
d. % d. Inserting comments in the code
12. What will be the output of the following program: 13. Compute the output of program:
for i in range(5): for i in range(0, 10, -1):
print(i) print(i)
else: a. Nothing will be printed.
print("done") b. This will print numbers from 0 to 9.
a. Error because else cannot be used without if c. This will print numbers from 9 to 0.
b. Error because else cannot be used without break d. This will print numbers from 1 to 9.
c. This will print numbers from 0 to 4 and a message
“done”
after that.
d. This will print numbers from 0 to 5 and a message
“done” after that.
14. Choose correct value to be printed by the following 15. Explain the difference between "while" and "for"
code when it executes? loops in Python.
sum = 0 a. "While" is used for indefinite iteration, and "for" is used
values = [1,3,5,9] for indefinite iteration
for number in values: b. "While" is used for indefinite iteration, and "for" is used
sum = sum + number for definite iteration
print(sum) c. They are synonyms and can be used interchangeably
a. 4
b. 0 d. "While" is used when number of iterations known, and
c. 18 "for" is used when number of iterations unknown
d. 16
16. What will be the output of the following python var1 = [3, 2, 5, 6, 0, 7, 9]
code? sum = 0
a. 8 12 sum1 = 0
b. 8 3 for elem in var1:
c. 8 18 if (elem%2 == 0):
d. 2 3 sum = sum +elem
continue
if (elem%3 == 0):
sum1 = sum1 + elem
print(sum, end = “ ”)
print(sum1)
17. Evaluate: 5794305 X 99999 and write answer 18. A box that can represent two different conditions.
a. Rectangle
b. Diamond
c. Circle
d. Parallelogram
19. Output of the following program is _________ 20. What is the result of executing the following code?
a=5 number = 5
b=2 while number <= 5:
a=a+b if number < 5:
b=a-b number = number + 1
a=a-b print(number)
print(a, b)
a. 5, 2 a. The program will loop indefinitely
b. 2, 5 b. The value of number will be printed exactly 1 time
c. 3, 2 c. The while loop will never get executed
d. 2, 3 d. The value of number will be printed exactly 5 times
Answers (SET B):
1. b
2. c
3. a
4. d
5. c
6. b
7. b
8. b
9. d
10. c
11. a) Identifying and fixing errors in code.
12. c
13. a
14. c
15. b
16. a
17. 579424705695
18. b
19. b
20. a
PSP (ITFC-0101) Quiz 1 (Set C) Date: Oct 18, 2023 MM:20
Name: Roll Number:
Batch: Branch:
1. Which of these collection designs a Tuple: 2. Find out an invalid data type in Python?
a. {“name”:”apple”, “color”:”green”} a. int
b. [“apple”, “banana”, “cherry”] b. string
c. (“apple”, “banana”, “Cherry”) c. decimal
d. {“apple”, “banana”, “cherry”} d. list
3. What is the output of the following program _____ 4. How to denote multiline comment in Python?
i=0 a. # Comment
while i < 3: b. /* Comment */
print (i) c. ''' Comment '''
i += 1 d. // Comment
else:
print (0)
a. 0 1 2 3 0
b. 0 1 2 3
c. 0 1 2
d. 0 1 2 0
5. What will be the output of the following code 6. What is computational thinking?
snippet? a. Solving problems using computers
print(2**3 + (5 + 6)**(1 + 1)) b. Programming without using a computer
a. 121 c. None of these
b. 129 d. A problem-solving method that involves breaking down
c. 28 a problem into smaller, manageable parts
d. 127
7. What is the value of expressions 8/4/2, 8/(4/2): 8. Evaluate: 5794035 X 99999 and write answer
a. (1.0, 1.0)
b. (4.0. 1.0)
c. (1.0, 4.0)
d. (4.0, 4.0)
9. What is the result of executing the following code? 10. What is the role of debugging in Python
number = 5 programming?
while number <= 5: a. Optimizing code for performance
if number < 5: b. Writing new code
number = number + 1 c. Identifying and fixing errors in code
print(number) d. Inserting comments in the code

a. The value of number will be printed exactly 1 time b.


b. The while loop will never get executed
c. The value of number will be printed exactly 5 times
d. The program will loop indefinitely
11. Output of following python expressions: 12. Choose correct value to be printed by the following
2**(3**2) code when it executes?
(2**3)**2 sum = 0
2**3**2 values = [1,3,5,9]
a. 512, 64, 512 for number in values:
b. 64, 512, 64 sum = sum + number
c. 512, 512, 512 print(sum)
d. 64, 64, 64 a. 4
b. 18
c. 0
d. 16
13. Which of the following operator has its 14. A box that can represent two different conditions.
associativity from right to left: a. Rectangle
a. ** b. Parallelogram
b. // c. Circle
c. + d. Diamond
d. %
15. What will be the output of the following program: 16. Output of the following program is _________
for i in range(5): a=5
print(i) b=2
else: a=a+b
print("done") b=a-b
a. Error because else cannot be used without if a=a-b
b. This will print numbers from 0 to 5 and a message print(a, b)
“done” after that. a. 5, 2
c. Error because else cannot be used without break b. 3, 2
d. This will print numbers from 0 to 4 and a message c. 2, 5
“done” after that. d. 2, 3
17. What will be the output of the following python var1 = [3, 2, 5, 6, 0, 7, 9]
code? sum = 0
a. 2 3 sum1 = 0
b. 8 3 for elem in var1:
c. 8 18 if (elem%2 == 0):
d. 8 12 sum = sum +elem
continue
if (elem%3 == 0):
sum1 = sum1 + elem
print(sum, end = “ ”)
print(sum1)

18. Compute the output of program: 19. Explain the difference between "while" and "for"
for i in range(0, 10, -1): loops in Python.
print(i) a. "While" is used when number of iterations known, and
a. This will print numbers from 9 to 0. "for" is used when number of iterations unknown
b. This will print numbers from 0 to 9. b. "While" is used for indefinite iteration, and "for" is used
c. Nothing will be printed. for indefinite iteration
d. This will print numbers from 1 to 9. c. "While" is used for indefinite iteration, and "for" is used
for definite iteration
d. They are synonyms and can be used interchangeably
20. Output of the following flow chart

a. 3 4 5 6 7
b. 2 4 6
c. 2 3 4 5 6
d. 3 5 7
Answers (SET C):
1. c
2. c
3. d
4. c
5. b
6. d
7. c
8. 579397705965
9. d
10. c
11. a
12. b
13. a
14. d
15. d
16. c
17. d
18. c
19. c
20. d
PSP (ITFC-0101) Quiz 1 (Set D) Date: Oct 18, 2023 MM: 20
Name: Roll Number:
Batch: Branch:
1. What will be the output of the following python var1 = [3, 2, 5, 6, 0, 7, 9]
code? sum = 0
a. 8 18 sum1 = 0
b. 2 3 for elem in var1:
c. 8 12 if (elem%2 == 0):
d. 8 3 sum = sum +elem
continue
if (elem%3 == 0):
sum1 = sum1 + elem
print(sum, end = “ ”)
print(sum1)
2. Find out an invalid data type in Python? 3. Output of following python expressions:
a. int 2**(3**2)
b. string (2**3)**2
c. list 2**3**2
d. decimal a. 64, 512, 64
b. 512, 64, 512
c. 512, 512, 512
d. 64, 64, 64
4. Compute the output of program: 5. What is the output of the following program _______
for i in range(0, 10, -1): i=0
print(i) while i < 3:
a. This will print numbers from 1 to 9. print (i)
b. Nothing will be printed. i += 1
c. This will print numbers from 0 to 9. else:
d. This will print numbers from 9 to 0. print (0)
a. 0 1 2 0
b. 0 1 2 3 0
c. 0 1 2
d. 0 1 2 3
6. Evaluate: 5793045 X 99999 and write answer 7. Output of the following program is _________
a=5
b=2
a=a+b
b=a-b
a=a-b
print(a, b)
a. 5, 2
b. 2, 3
c. 3, 2
d. 2, 5
8. What is the role of debugging in Python 9. What is the result of executing the following code?
programming? number = 5
a. Writing new code while number <= 5:
b. Identifying and fixing errors in code if number < 5:
c. Optimizing code for performance number = number + 1
d. None of the above print(number)

a. The value of number will be printed exactly 1 time


b. The while loop will never get executed
c. The program will loop indefinitely
d. The value of number will be printed exactly 5 times
10. What will be the output of the following code 11. What is the value of expressions 8/4/2, 8/(4/2):
snippet? a. (1.0, 1.0)
print(2**3 + (5 + 6)**(1 + 1)) b. (4.0. 1.0)
a. 28 c. (1.0, 4.0)
b. 129 d. (4.0, 4.0)
c. 121
d. 127
12. A box that can represent two different conditions. 13. How to denote multiline comment in Python?
a. Diamond a. // Comment
b. Rectangle b. /* Comment */
c. Circle c. ''' Comment '''
d. Parallelogram d. # Comment

14. Which of the following operator has its 15. What will be the output of the following program:
associativity from right to left: for i in range(5):
a. + print(i)
b. ** else:
c. % print("done")
d. // a. This will print numbers from 0 to 4 and a message
“done” after that.
b. Error because else cannot be used without if
c. Error because else cannot be used without break
d. This will print numbers from 0 to 5 and a message
“done” after that.
16. Explain the difference between "while" and "for" 17. Choose correct value to be printed by the following
loops in Python. code when it executes?
a. "While" is used for definite iteration, and "for" is used sum = 0
for indefinite iteration values = [1,3,4,7]
b. They are synonyms and can be used interchangeably for number in values:
c. "While" is used for indefinite iteration, and "for" is sum = sum + number
used for definite iteration print(sum)
d. "While" is used when number of iterations known, a. 18
and "for" is used when number of iterations unknown b. 7
c. 15
d. 0
18. Output of the following flow chart

a. 357
b. 246
c. 23456
d. 34567

19. Which of these collection designs a Tuple: 20. What is computational thinking?
a. {“name”:”apple”, “color”:”green”} a. Solving problems using computers
b. [“apple”, “banana”, “cherry”] b. Programming without using a computer
c. {“apple”, “banana”, “cherry”} c. None of these
d. (“apple”, “banana”, “Cherry”) d. A problem-solving method that involves breaking
down a problem into smaller, manageable parts
Answers (SET D):

1. c
2. d
3. b
4. b
5. a
6. 579298706955
7. d
8. b
9. c
10. b
11. c
12. a
13. c
14. b
15. a
16. c
17. c
18. a
19. d
20. d

You might also like