Unit 1 - Practice Quiz

INT108 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which of the following is a major difference between Python 2 and Python 3 regarding the print statement?

A. There is no difference
B. Python 3 does not have a print function
C. Python 3 uses parentheses for print, while Python 2 does not require them
D. Python 2 uses parentheses for print, while Python 3 does not require them

2 What is the standard file extension for Python scripts?

A. .pyt
B. .py
C. .pn
D. .pt

3 Which command is typically used in the Windows Command Prompt to run a Python file named 'script.py'?

A. run script.py
B. go script.py
C. execute script.py
D. python script.py

4 What is the correct syntax to output 'Hello World' in Python 3?

A. console.log('Hello World')
B. echo 'Hello World'
C. print('Hello World')
D. System.out.println('Hello World')

5 Which symbol indicates that the Python interpreter is running in interactive mode?

A. $$$
B. ---
C. ###
D. >>>

6 Which of the following is a valid variable name in Python?

A. 2my_var
B. my var
C. my-var
D. _my_var

7 What happens if you try to use a variable that has not been defined?

A. A TypeError occurs
B. The program returns 0
C. A NameError occurs
D. The program returns None

8 Which operator is used to assign a value to a variable?

A. ->
B. =
C. :
D. ==

9 Python is a case-sensitive language. What does this mean?

A. 'Variable' and 'variable' are different identifiers
B. Keywords must always be uppercase
C. Variables must always be uppercase
D. 'Variable' and 'variable' are the same

10 Which of the following is a Python keyword?

A. integer
B. yield
C. variable
D. print

11 What function is used to check the data type of a value?

A. typeof()
B. class()
C. type()
D. check()

12 What is the data type of the value 3.14?

A. bool
B. str
C. float
D. int

13 What is the data type of the value '10'?

A. str
B. float
C. bool
D. int

14 Which of the following represents a Boolean value in Python?

A. true
B. TRUE
C. True
D. 1.0

15 What is a 'statement' in Python?

A. A syntax error
B. A math equation only
C. A comment line
D. A unit of code that the Python interpreter can execute

16 Which of the following is an example of an expression?

A. x = 5
B. if x > 5:
C. import os
D. 5 + 10

17 What is the result of the floor division operation: 7 // 2?

A. 3.5
B. 4
C. 3
D. 2

18 Which operator calculates the remainder of a division?

A. //
B. %
C. /
D. #

19 What is the result of 2 ** 3?

A. 9
B. 6
C. 5
D. 8

20 What is the output of the following code: print(10 / 2)?

A. 2
B. 5.0
C. 10
D. 5

21 Following the order of operations (PEMDAS), what is the result of 2 + 3 * 4?

A. 20
B. 14
C. 10
D. 24

22 Which character starts a single-line comment in Python?

A. /*
B. #
C. --
D. //

23 What happens when you use the '+' operator on two strings?

A. It throws a TypeError
B. It adds the ASCII values
C. It concatenates the strings
D. It subtracts them

24 What happens when you use the '' operator on a string and an integer (e.g., 'Hi' 3)?

A. TypeError
B. It adds the number to the string
C. It creates a list
D. It repeats the string 3 times

25 What is the result of executing: print('5' + 5)?

A. NaN
B. TypeError
C. 55
D. 10

26 Variables in Python are 'dynamically typed'. What does this mean?

A. You must declare the type before assigning a value
B. Variables cannot change values
C. Variables are strictly typed like C++
D. A variable can hold different types of values at different times

27 Which naming convention is recommended for Python variable names?

A. PascalCase
B. kebab-case
C. snake_case
D. camelCase

28 What is the associativity of the exponentiation operator (**) in Python?

A. Left-to-right
B. Right-to-left
C. Random
D. Center

29 What is 'Composition' in the context of Python expressions?

A. Combining simple expressions and statements into compound ones
B. Installing Python packages
C. Compiling code to C
D. Writing comments

30 Which of the following variable names leads to a SyntaxError?

A. klass
B. clazz
C. class
D. Class_Name

31 What does the function input() return by default?

A. str
B. int
C. list
D. float

32 Why are comments important in programming?

A. They make the code run faster
B. They encrypt the code
C. They explain what the code does to humans
D. They are required by the compiler

33 What is the result of: 10 % 3?

A. 10
B. 3.33
C. 1
D. 3

34 Which of the following is NOT an assignment statement?

A. 17 + 3
B. pi = 3.14159
C. message = 'Hello'
D. n = 17

35 How do you represent a string literal in Python?

A. Only double quotes
B. Either single or double quotes
C. Parentheses
D. Only single quotes

36 What identifies the values acted upon by an operator?

A. Keywords
B. Comments
C. Operands
D. Functions

37 If x = 10 and y = 20, what is the result of: print(x, y)?

A. x y
B. 10 20
C. 1020
D. 30

38 Which of the following creates a multi-line string or comment?

A. <!-- -->
B. ''' (triple quotes)
C. #
D. //

39 What error is raised if you write: print 'Hello' in Python 3?

A. ValueError
B. SyntaxError
C. NameError
D. TypeError

40 What is the binary operator for multiplication?

A. mul
B. *
C. x
D. #

41 Which of the following is an illegal variable name?

A. _catch22
B. catch_22
C. CATCH22
D. 22_catch

42 If you define variable x = 10 and then x = 'Hello', what happens?

A. x keeps the value 10
B. Error: Type mismatch
C. The program crashes
D. x now holds the string 'Hello'

43 The term 'IDLE' in Python stands for:

A. Integrated Development and Learning Environment
B. Internal Developer Loop Engine
C. Integrated Debugging Line Editor
D. Interactive Design Language Environment

44 Which of the following statements assigns the string 'Python' to the variable named language?

A. language = 'Python'
B. set language 'Python'
C. 'Python' = language
D. language == 'Python'

45 What will be the output of: print(3 * '7')?

A. 37
B. Syntax Error
C. 777
D. 21

46 Which character is used to separate two statements on a single line?

A. /
B. ;
C. ,
D. :

47 In the expression (5 + 2) * 3, which operation happens first?

A. Addition
B. Evaluation from left to right regardless
C. Multiplication
D. None

48 What will the following code output? print(type('5.5'))

A. <class 'bool'>
B. <class 'float'>
C. <class 'int'>
D. <class 'str'>

49 What does a SyntaxError generally indicate?

A. The logic of the program is wrong
B. The variable name is not found
C. The code violates the grammatical rules of Python
D. There is a division by zero

50 When you install Python on Windows, what needs to be added to the PATH variable to run python from any command prompt?

A. The My Documents folder
B. The directory where python.exe is located
C. Nothing, it works automatically
D. The browser history