Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
Give this quiz to my class
Q 1/20
Score 0
Which of the following is a valid variable name in Python?
30
my_variable
@myvariable
my-variable
2nd_variable
Q 2/20
Score 0
What is the result of the following code: x = 10; y = 5; z = x + y; print(z)?
30
5
20
15
10
20 questions
Q.
Which of the following is a valid variable name in Python?
1
30 sec
Q.
What is the result of the following code: x = 10; y = 5; z = x + y; print(z)?
2
30 sec
Q.
Which of the following cannot be used as a Python variable name?
3
30 sec
Q.
What will happen if you try to assign a string to a variable using single quotes and forget to close the quotes?
4
30 sec
Q.
What will the following code output: name = 'Alice'; print(name + ' is here.')?
5
30 sec
Q.
What is the correct way to declare a variable and assign the value 42 in Python?
6
30 sec
Q.
Which of the following statements is true about variable naming conventions in Python?
7
30 sec
Q.
What is the output of the following code: score = 100; print('Your score is: ' + str(score))?
8
30 sec
Q.
What function is used in Python to output text to the console?
9
30 sec
Q.
Which function is used in Python to capture user input from the console?
10
30 sec
Q.
What will the following code print if the user enters 'Python' when prompted: name = input('Enter your favorite programming language: '); print('You like ' + name + '!')
11
30 sec
Q.
What will the following code output if the user types '2' and then '3': first = input('Enter first number: '); second = input('Enter second number: '); print(first + second)
12
30 sec
Q.
Which function would you use to convert a float to an integer in Python?
13
30 sec
Q.
What will be the result of the expression int(4.9) in Python?
14
30 sec
Q.
What will be the output of the following code: print(int(3.7) + int(2.3))?
15
30 sec
Q.
Which function from the random library can generate a random integer between two specified values in Python?
16
30 sec
Q.
What is the purpose of the random.shuffle() function in Python?
17
30 sec
Q.
Which function from the random library can be used to generate a random floating-point number between 0.0 and 1.0?
18
30 sec
Q.
What is the output of the following code snippet: import random; print(random.randint(1, 5))?
19
30 sec
Q.
In Python's random library, which function would you use to simulate the rolling of a six-sided die?