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. Python 3 uses parentheses for print, while Python 2 does not require them
B. Python 2 uses parentheses for print, while Python 3 does not require them
C. There is no difference
D. Python 3 does not have a print function

2 What is the standard file extension for Python scripts?

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

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

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

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

A. System.out.println('Hello World')
B. print('Hello World')
C. console.log('Hello World')
D. echo '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. my-var
B. _my_var
C. 2my_var
D. my var

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

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

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 the same
B. 'Variable' and 'variable' are different identifiers
C. Keywords must always be uppercase
D. Variables must always be uppercase

10 Which of the following is a Python keyword?

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

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

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

12 What is the data type of the value 3.14?

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

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

A. float
B. bool
C. str
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 comment line
C. A math equation only
D. A unit of code that the Python interpreter can execute

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

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

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

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

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. 5.0
B. 2
C. 5
D. 10

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

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

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 subtracts them
B. It adds the ASCII values
C. It throws a TypeError
D. It concatenates the strings

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

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

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

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

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

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

27 Which naming convention is recommended for Python variable names?

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

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

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

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

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

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

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

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

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

32 Why are comments important in programming?

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

33 What is the result of: 10 % 3?

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

34 Which of the following is NOT an assignment statement?

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

35 How do you represent a string literal in Python?

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

36 What identifies the values acted upon by an operator?

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

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

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

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

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

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

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

40 What is the binary operator for multiplication?

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

41 Which of the following is an illegal variable name?

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

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

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

43 The term 'IDLE' in Python stands for:

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

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

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

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

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

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. None
B. Evaluation from left to right regardless
C. Addition
D. Multiplication

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

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

49 What does a SyntaxError generally indicate?

A. The code violates the grammatical rules of Python
B. The variable name is not found
C. The logic of the program is wrong
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. Nothing, it works automatically
B. The directory where python.exe is located
C. The My Documents folder
D. The browser history