WorksheetsProgramming Basics Quiz
Total questions: 20
Worksheet time: 10mins
What is a variable in programming?
A fixed value
A storage location identified by a name
A type of loop
A function that returns a value
Which of the following is NOT a data type?
Integer
String
Float
Loop
What is an example of a String data type?
123
12.34
"Hello, World!"
True
How do you declare an integer variable in Python?
int x = 5
x = 5
declare x as integer = 5
x: int = 5
Which operator is used for addition in programming?
+
&
*
/
What is the output of the following code? print(3 + 2 * 2)
10
7
8
5
Which of the following is a correct way to create a list in Python?
list = (1, 2, 3)
list = [1, 2, 3]
list = {1, 2, 3}
list = 1, 2, 3
What is the purpose of the input() function?
To output data to the console
To read data from the user
To initialize variables
To store data in a file
What data type is returned by the input() function?
Integer
String
Float
Boolean
How can you convert a string to an integer in Python?
int("123")
str(123)
float("123")
convert("123")
What is the result of the following expression: 5 != 5?
True
False
0
1
Which symbol is used for the modulus operation in Python?
/
%
*
+
What does the following code output? print("Hello" + " World")
Hello World
HelloWorld
Hello + World
Error
Which of the following is a valid variable name in Python?
1st_variable
first-variable
first_variable
first variable
What will be the output of the following code? print(10 // 3)
3.33
3
4
3.0
What is the function of the len() function in Python?
To find the length of a string or list
To count the number of variables
To convert data types
To create a new variable
How do you create a dictionary in Python?
dict = { "key": "value" }
dict = [ "key": "value" ]
dict = ( "key", "value" )
dict = < "key": "value" >
Which of the following statements is true about comments in Python?
They are ignored by the interpreter
They start with #
Both A and B
They must be at the end of a line
What will the following code output? x = 5; y = x + 2; print(y)
5
7
2
0
Which statement is used to check a condition in Python?
if
check
condition
evaluate
