stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Python Review - Stage 1 Flashcards | StudBud
Explore
/
Python Review - Stage 1
Python Review - Stage 1
30 terms
·
StudBud Administration
Imported from external platform
Flashcards
30 cards
F
Practice quiz
P
Host live
L
Questions
30
Answers
1
Which keyword do you use to check if a value is in a list in Python?
in
by
to
at
2
What does a user-defined function allow you to do?
Create a list
Add two numbers together
Define your own operations and logic
Add two numbers together
3
What is the purpose of variables in Python?
To create loops
To store and manage data
To display information to the screen
To perform mathematical operations
4
How do you check if two strings are equal in Python?
Using the equals() function
Using the == operator
Using the is_equal() function
Using the = operator
5
How do you add an element to the end of a list in Python?
list.add(new_element)
list.append(new_element)
list.insert(0, new_element)
list.extend(new_element)
6
What is the correct way to access the first element of a list in Python?
list.first()
list[0]
list(0)
list.get[0]
7
What is the result of the expression
"Hello, " + "World!"
in Python
"Hello,World!"
"Hello, World!"
"Hello, "
"Hello, " + "World!"
8
How do you pass a parameter to a function in Python?
By using the keyword byvalue
By using the keyword var
By placing the parameter inside the parentheses when calling the function
By enclosing the parameter in square brackets when calling the function
9
How do you write a FOR loop that displays the numbers 1 to 5?
for i in 1 to 5:
for i in [1, 2, 3, 4, 5]:
for i in range(5):
for i in range(1, 6):
10
What is the purpose of Python's
print()
function?
To define (create) a function
To add numbers together
To create a list
To display output on the screen
11
Which of the following is NOT a valid data type in Python?
string
integer
number
list
12
What is Python?
A computer brand
A type of snake
A data structure
A programming language
13
What keyword is used to send a value from a function?
stop
return
send
exit
14
Which of the following is a valid way to comment out a single line of code in Python?
# This is a comment
// This is a comment
<!-- This is a comment -->
/* This is a comment */
15
Which keyword is used to make a decision in Python?
while
if
for
assignment
16
What is the correct way to create and initialise a variable in Python?
value = variable_name
= variable_name, value
variable_name, value
variable_name = value
17
How do you iterate through a list in Python using a FOR loop?
for i in list:
for i in range(len(list)):
for i in list.items():
for i in 1 to len(list)
18
What does the
input
function do in Python?
It performas advanced mathematical calculations
It generates random numbers.
Is displays a text message to the screen
It waits for the user to enter text and returns that text as a string.
19
What is the result of the expresion
5 % 2
in Python?
2.5
1
1.5
2
20
What is the purpose of the
elif
keyword in an
if-elif-else
statement in Python?
To define (create) a function
To skip the current condition and move to the next IF condition.
To create a new condition that is checked only if the IF condition is True
To indicate the end of the conditional statement
21
Which operator is used to check if two values are equal in Python?
!=
==
<
=
22
What is the purpose of the
len()
function in Python?
To display text, character by character, to the screen
To create a list of 5 elements
To calculate mathematical expressions
To find out how many characters/items are in a string/list
23
Which statement removes the item as the end of a Python list?
list.get()
list.pop()
list.clear()
list.delete()
24
What statement shows an example of
selection
in Python?
print("Hello, World!")
if temperature > 30:
while x < 10:
for i in range(5):
25
What is the purpose of the
break
statement in a Python loop?
To execute a block of code repeatedly.=
To continue to the next iteration of the loop
To exit the loop earlier than intended
To create an infinite loop
26
Which function is used to convert a string to an integer in Python?
int()
str()
bool()
float()
27
Which data type is used to store whole numbers?
integer
Boolean
float
string
28
What does the WHILE loop do in Python?
It calculates mathematical expressions
It outputs numbers in a sequence
It defines (creates) a function
It repeats a block of code as long as a condition is true
29
What is the purpose of an IF statement?
To display text to the screen
To create a loop
To create a function
To make a decision based on a condition
30
What is the purpose of the
else
clause in an IF statement?
To create a loop
To execute code when the IF condition is False
To terminate the program
To define a new condition