Exercise - Introduction to Python Programming
Multiple Choice Questions
1. Which of the following steps is NOT part of the basic programming process?
- (a) Write Code
- (b) Compile/Interpret
- (c) Execute
- (d) Ignore Errors
2. What should you do when installing Python to run it from the command line more easily?
- (a) Uncheck "Add Python to PATH"
- (b) Choose a different IDE
- (c) Check "Add Python to PATH"
- (d) Install only the IDE
3. What will be the output of: print(10 // 3)?
- (a) 3.333
- (b) 3
- (c) 1
- (d) 4
4. What does the input() function return?
- (a) Integer
- (b) Float
- (c) String
- (d) Boolean
5. Which operator has the highest precedence in Python?
- (a) Addition (+)
- (b) Multiplication (*)
- (c) Exponentiation (**)
- (d) Parentheses ()
6. What is the result of 5 > 3 and 2 < 1?
- (a) True
- (b) False
- (c) Error
- (d) None
7. What does the += operator do?
- (a) Adds two numbers
- (b) Compares values
- (c) Adds and assigns
- (d) Multiplies values
8. Which function converts string to integer?
- (a) str()
- (b) int()
- (c) float()
- (d) input()
9. What is the output of the below code? age = 25; print (" Age: ", age )
- (a) Age: 25
- (b) 25
- (c) Age
- (d) age
10. Which symbol is used for comments in Python?
- (a) //
- (b) /*
- (c) #
- (d) --
Short Answer Questions
1. Why are comments important in programming?
2. Discuss three basic data types in python.
3. Describe the difference between integer and float data types in Python.