1.What is the output of the following code?
numbers = [1, 2, 3]
for num in numbers:
if num == 2:
break
print(num)
PYTHON QUIZ-I
Quiz
•
Computers
•
University
•
Hard
SRINIVASARAO 22PHD7042
Used 1+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
1.What is the output of the following code?
numbers = [1, 2, 3]
for num in numbers:
if num == 2:
break
print(num)
1
12
123
None
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
2.What is the output of the following code?
x = 10
if x > 5:
print("x is greater than 5")
else:
print("x is less than or equal to 5")
x is greater than 5
x is less than or equal to 5
Error
None
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
3.Which of the following statements is true about while loops in Python?
The loop executes a fixed number of times.
The loop executes as long as the condition is true.
The loop executes only once.
The loop condition is optional.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
4.What is the output of the following code?
def multiply(a, b=2):
return a * b
print(multiply(3))
6
3
Error
None
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
5.What is the correct way to open a file in write mode?
open('file.txt', 'r')
open('file.txt', 'w')
open('file.txt', 'rw')
open('file.txt')
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
6.Which of the following statements about Python functions is false?
Functions can return multiple values.
Functions can have default parameters.
A function must always have a return statement
Functions can be nested inside other functions.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
7.What will be the output of this code?
x = 5 while x > 0: print(x, end=" ") x -= 1
5 4 3 2 1
5 4 3 2 1 0
5 4 3 2
None
20 questions
loops and iterables in python
Quiz
•
University
16 questions
PAP Module-3 Part-2
Quiz
•
University
15 questions
Python Quiz Ver- 1.3
Quiz
•
University
20 questions
[Python For All] Quiz 2 - Rewind.py
Quiz
•
University
17 questions
Python Loops
Quiz
•
University
25 questions
Quiz 2
Quiz
•
University
15 questions
Python Basics
Quiz
•
University
20 questions
Python Programming II CSE A
Quiz
•
12th Grade - University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade