Python Programming Quiz

Python Programming Quiz, Questions & Answers on Python Language Fundamentals, Data Structures, Control Flow, and Object-Oriented Programming.

Python Programming Quiz

1) What is the file extension for Python files?

.pyth

.py

.pyt

.pt

2) What is the correct syntax to output “Hello Python” in Python?

output (“Hello Python”)

display (“Hello Python”)

print (“Hello Python”)

pt (“Hello Python”)

3) Is Python Case-sensitive Language?

No

Yes

4) Python is weak in___________

Machine Learning and Artificial Intelligence

Mobile Software Development

Scientific and Numeric Software Development

Data Science and Data Visualization

5) How do we insert COMMENTS in Python code?

//This is a comment

*This is a comment

#This is a comment

“This is a comment

6) Is Python Object Oriented Programming Language?

Yes

No

7) What is the best IDE to learn Python?

Eclipse PyDev

IDLE

PyCharm

Visual Studio Code

8) Is Python supports the explicit declaration of Data Types?

Yes

No

9) It is _____ not a Python Data Structure?

List

Dictionary

Tuple

Group

10) Which keyword is used to define functions in Python?

function

def

method

func

11) Which operator can be used to compare two values?

<>

==

><

=

12) What can you put before and after a section to make all of the lines a comment?

”’

///

###

***

13) How do you create a variable “x” that is equal to 2?

var x = 2

int x = 2

x = 2

variable x = 2

14) Which of the following is not a valid assignment operator?

+=

-=

*=

X=

15) Which one of the following is a valid Python if statement

if a >= 22:

if (a >= 22)

if (a => 22)

if a >= 22

16) What keyword would you use to add an alternative condition to an if statement?

else if

elseif

elif

None of the above

17) Which of the following is a valid for loop in Python?

for(a = 0; a < 3; a++)

for a in range(3)

for a loop 3:

for a in range(1,3):

18) If you have a variable “abcd”, how do you check to see what type of variable you are working with?

getType(abcd)

Type(abcd)

type(abcd)

abcd.type

19) Which of the following is a valid tuple in Python?

sampleTuple = (1,2,3,4,5)

sampleTuple = {1,2,3,4,5}

sampleTuple = [1,2,3,4,5]

sampleTuple = /1,2,3,4,5/

20) What is the keyword used after the try statement to handle exceptions?

catch

exception

next

except


Python Step by Step Tutorial
Python Video Tutorial
Follow me on social media: