0% found this document useful (0 votes)
99 views5 pages

Python Basics Quiz: Week 2 Questions

The document contains a series of Python programming questions and answers, covering topics such as arithmetic operations, variable naming, data types, functions, and input/output. Each question is followed by multiple-choice answers, with the correct answer indicated. This serves as a quiz or review material for learning Python basics.

Uploaded by

yashvichopda24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views5 pages

Python Basics Quiz: Week 2 Questions

The document contains a series of Python programming questions and answers, covering topics such as arithmetic operations, variable naming, data types, functions, and input/output. Each question is followed by multiple-choice answers, with the correct answer indicated. This serves as a quiz or review material for learning Python basics.

Uploaded by

yashvichopda24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Week 2

1. What is the output of print(3 + 4 * 2)?


a) 14
b) 11
c) 10
d) 7
Answer: b) 11

2. Which of these is a valid variable name in Python?


a) 2value
b) value_2
c) value-2
d) value 2
Answer: b) value_2

3. What does the input() function do?


a) Outputs text to the screen
b) Takes input from user
c) Declares a variable
d) Converts a string to int

Answer: b) Takes input from user

4. Which of the following is not a valid data type in Python?


a) int
b) float
c) real
d) str

Answer: c) real

5. What is the output of type(5.0)?


a) int
b) float
c) str
d) bool

Answer: b) float

6. Which operator is used for exponentiation in Python?


a) ^
b) **
c) %
d) //

Answer: b) **

7. What is the result of int("5") + 2?


a) 52
b) 7
c) Error
d) "7"

Answer: b) 7

8. Which of the following can be used to take a number as input from the user?
a) input()
b) int(input())
c) str(input())
d) Both a and b

Answer: d) Both a and b

9. What is the output of print("Hello" + "World")?


a) Hello World
b) HelloWorld
c) Error
d) Hello+World

Answer: b) HelloWorld

10. Which of these statements assigns a float value to a variable?


a) x = 10
b) x = 10.5
c) x = "10"
d) x = '10'

Answer: b) x = 10.5

11. What is the result of 7 // 2 in Python?


a) 3.5
b) 4
c) 3
d) 2

Answer: c) 3

12. Which keyword is used to define a function in Python?


a) function
b) def
c) define
d) func

Answer: b) def

13. Which one is a comment in Python?


a) // This is a comment
b) <!-- This is a comment -->
c) # This is a comment
d) /* This is a comment */

Answer: c) # This is a comment

14. What is the output of print("10" * 2)?


a) 20
b) 1010
c) Error
d) 102

Answer: b) 1010

15. What is the output of print(type("Hello"))?


a) str
b) string
c) <class 'str'>
d) text

Answer: c) <class 'str'>

16. What does float("3.14") return?


a) "3.14"
b) 3.14
c) Error
d) 314

Answer: b) 3.14

17. What is the result of 5 % 2?


a) 2
b) 2.5
c) 1
d) 0

Answer: c) 1

18. What happens if you add a string and an integer? Like "Hello" + 5
a) "Hello5"
b) Error
c) 5
d) Hello

Answer: b) Error

19. Which of the following is used to print output in Python?


a) write()
b) echo
c) print()
d) out()

Answer: c) print()

20. What is the value of x after this code runs?


x = 10
x=x+5
a) 5
b) 10
c) 15
d) 20

Answer: c) 15

You might also like