Thursday, April 23, 2020

Python quiz with questions and answers

Python is popular because it is a general-purpose programming language used in any building any programs, it can be used in building almost any real-world applications. Examples of web applications include Quora, YouTube, Dropbox Pinterest, etc,. Examples of Standalone applications such as sublime text, NetBeans, Koding, BitTorrent, etc,. Raspberry PI is also developed using Python programming language.

Not only building the Softwares but also it is widely used in DevOps environments for continuous integration and continuous deployment

Take a quiz and assess your level of experience with Python tool, if you can score more than 6, then you can start directly with intermediate-level courses by brushing up basics, if your score is below 6, you can start taking a beginners level course, you can refer to the courses.
Python quiz with questions and answers


Question 1. What is the correct syntax to output "Hello World" in Python?

A. p("Hello World")
B. echo "Hello World"
C. Print("Hello World");
D. echo("Hello World")


Answer: Option C


 Question 2. How do you insert COMMENTS in Python code?

A. //This is a comment
B. /*This is a comment*/
C. #This is a comment
D. /#This is a comment


Answer: Option C
Example:
print("This will run.")  #This won't run
Print function will output "this will run" and letter after # won't run, python interpreter will ignore the letter after # in that particular line

Question 3. Python is _ programming language?

High-level programming language
General-purpose programming language
Scripting language
All the Above


Answer: Option D
Python is a high-level programming language which means humans can easily understand the code. Low-level languages are machine level languages that can be understood by machines. Python is called scripting language because it was an interpreter to translate its source code. It is called a general-purpose programming language because it can be used to build any real-world applications


 Question 4. Python executes source code using

A. Interpreter
B. Translator
C. Compiler
D. All the above

Answer: Option A
As mentioned in the previous question, python uses an interpreter to translate and execute the code. The main difference is that the interpreter translates and executes code at once whereas the compiler translates the code into machine level language and then executes the programs. The best examples of the compiler are C, Java. Examples of the interpreter are, Python, Ruby, Perl programming examples


Question 5. In order to run Python programs, what is the correct file extension for Python files?

A .pyth

C .pt
D .pyt


Answer: Option B
All the files should save as .py file extension, in order to run the python scripts.


 Question 6. What is the correct way to create a function in Python?

A. function myfunction():
B. 
C. 
D. Fn function()


Answer : Option C 


 Question 7. What is the output of the following code?
eval(''1 + 3 * 2'')


B. 
C.
D. ‘1+3*2’

Answer: Option C
Eval is a method used to evaluate the values entered in the braces


 Question 8. What is the output of below? 33 == 33.0

A. False
B. 33
C. True
D. None of the above


Answer: Option C
Explanation

comparison operator evaluates true and false. And in python, we need not specify whether the number is int or float.


 Question 9. What is the difference between a class and an object in Python?

A. 
B. 
C. 
D. 

Answer: Option A


 Question 10. What will this code print?
>>> a=10
>>>   print(a+10)

A. 
B. a+10
C. None of these
D. 

Answer: Option D
This code will raise an exception because you cannot put whitespace before a statement. It raises a SyntaxError for unexpected indent.



Based on your score, if you can score more than 6, then you can start directly with intermediate-level courses by brushing up basics, if your score is below 6, you can start taking a beginners level course, you can refer to the courses. you can refer to the top 10 best python courses online and take the courses accordingly. 


EmoticonEmoticon