Lancecourse
Courses
How-tos
Blog
Sign In
Sign Up
free
Francais
Python Basics chapter 2 quiz
Test Your Knowledge on Variables, Printing, Data Types, and Arithmetic Operations!
Question 1
What is the correct way to declare a constant variable in Python?
A) const PI = 3.14
B) PI = 3.14
C) pi = 3.14
D) constant PI = 3.14
Question 2
Which of these arithmetic operators performs exponentiation?
A) ^
B) **
C) //
D) %
Question 3
What is the data type of `3.14` in Python?
A) int
B) float
C) double
D) decimal
Question 4
What will be the result of `int("3.14")`?
A) 3.14
B) 3
C) Error
D) 314
Question 5
What will `print(10 / 3)` output?
A) 3
B) 3.3
C) 3.33...
D) 3.0
Question 6
What will be the output of the following code?
x =
10
x +=
5
print
(x)
A) 10
B) 5
C) 15
D) Error
Question 7
Which function is used to convert a number to a string?
A) to_string()
B) str()
C) convert()
D) stringify()
Question 8
Which of the following is a valid variable name in Python?
A) 2variable
B) my_variable
C) my-variable
D) my variable
Question 9
What will be printed by the following code?
print(
type
(
"10"
))
A) <class 'int'>
B) <class 'float'>
C) <class 'str'>
D) <class 'char'>
Question 10
What will be the output of the following code?
x =
5
y =
"5"
print(
x
+ int(
y
))
A) 10
B) 55
C) Error
D) 5
Answer all the questions then submit.
Submit Answers