
Py Day 5

Quiz
•
Computers
•
1st - 5th Grade
•
Hard
hichem ayari
Used 1+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the random.randint(a, b)
function in Python?
Generate a random integer between a (inclusive) and b (exclusive).
Generate a random integer between a (inclusive) and b (inclusive).
Generate a random float between a (inclusive) and b (exclusive).
Generate a random float between a (inclusive) and b (inclusive).
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
To use the random
module in Python, what is the correct way to import it?
import random.random
import random
from random import random
from random import random as rand
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you create an empty list in Python?
list()
[]
new list[]
empty_list = []
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to access the element at index 2 in a list named my_list
?
my_list[2]
my_list.get(2)
my_list.at(2)
get_element(my_list, 2)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of a 'for' loop in Python?
It is used to iterate over elements in a list or other iterable objects
It is used to execute a block of code repeatedly for a specified number of times
It is used to generate random numbers and store them in a list.
It is used to declare and initialize lists in Python.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to write a 'for' loop that prints each element in the list my_list
?
for i in range(len(my_list)): print(my_list[i])
for i in my_list: print(my_list[i])
for element in my_list: print(element)
for index in range(my_list): print(my_list[index])
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the range()
function in Python?
It generates a sequence of integers from 0 up to, but not including, a specified number.
It generates a sequence of integers from 1 up to, and including, a specified number.
It generates a sequence of integers with a specified start, end, and step size.
It generates a sequence of even numbers from 2 up to, and including, a specified number.
8.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct way to create a range that includes numbers from 1 to 10?
range(1, 10)
range(1, 11)
range(11)
range(1, 10, 1)
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
for num in range(2, 10, 3):
print(num)
2 3 4 5 6 7 8 9
2 5 8
2 4 7 10
2 5 8 11
Similar Resources on Wayground
10 questions
ICT Yr 5 - Programming in LOGO (Part 1)

Quiz
•
5th Grade
12 questions
Devices and variables

Quiz
•
5th Grade
13 questions
All you need to know about computers - Grade 1

Quiz
•
1st Grade
10 questions
Aleatorios y funciones

Quiz
•
4th Grade
10 questions
Personalizing Windows 10

Quiz
•
4th - 5th Grade
12 questions
Python Quiz - Basics & Turtle

Quiz
•
3rd - 8th Grade
10 questions
Web Design

Quiz
•
5th Grade
13 questions
Питонимся

Quiz
•
1st - 5th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade