Exit Chapter 04 ยท ๐Ÿš€ Getting Started with Python โ€” Quiz

Playing as a guest? to earn XP and track your progress.

Question 1 of 52 0 correct so far

๐Ÿš€ Getting Started with Python Quiz

Q1.

What is a program?

Explanation

A program is a set of instructions given to a computer to perform a specific task.

Q2.

Which of the following is a low-level language?

Explanation

Machine language and assembly language are low-level (close to the hardware); Python, Java and C++ are high-level.

Q3.

Why are high-level languages easier for humans to use?

Explanation

High-level languages are English-like, so they are easy to read, write and debug.

Q4.

Who created Python?

Explanation

Python was created by Guido van Rossum, a Dutch programmer.

Q5.

In which year was Python first released?

Explanation

Python was first released publicly in February 1991.

Q6.

In which country was Python developed?

Explanation

Python was created at CWI in the Netherlands.

Q7.

Python is named after:

Explanation

Python is named after the BBC comedy show 'Monty Python's Flying Circus', not the snake.

Q8.

Python was influenced by which two languages?

Explanation

Python is based on (influenced by) the ABC language and Modula-3.

Q9.

Which statement best describes Python?

Explanation

Python is a high-level, interpreted, general-purpose, object-oriented programming language.

Q10.

Which Python version series is in current use?

Explanation

The current series is Python 3.x; Python 3.0 came in 2008 and Python 2 ended in 2020.

Q11.

Django and Flask are Python tools used mainly for:

Explanation

Django and Flask are used to build websites and web applications.

Q12.

Which is NOT listed as an advantage (plus) of Python?

Explanation

Python is not the fastest language โ€” being interpreted, it is slower than compiled languages such as C/C++.

Q13.

Python is called an 'expressive language' because:

Explanation

In Python, fewer lines of code do more work โ€” for example, swapping two variables takes one line.

Q14.

What is the output of this code?

a, b = 5, 10 a, b = b, a print(a, b)

Explanation

a, b = b, a swaps the two values, so a becomes 10 and b becomes 5.

Q15.

The phrase 'batteries included' describes which feature of Python?

Explanation

'Its completeness' means a huge standard library (math, random, statistics and more) comes with Python.

Q16.

Python being 'cross-platform' means:

Explanation

Cross-platform (platform independent) means the same Python program runs on different operating systems unchanged.

Q17.

Which of these is a limitation (minus) of Python?

Explanation

Python is not strong on type-binding: a variable can hold any type, and some type mismatch errors are caught only at runtime.

Q18.

Why is converting a Python program to another language considered difficult?

Explanation

'Not easily convertible' โ€” Python's syntax differs a lot from other languages, so translating it is not easy.

Q19.

In which area does Python have fewer libraries compared with older languages?

Explanation

Python has lesser libraries in some specialised areas, such as mobile app development.

Q20.

A student writes 'Python is a compiled language.' Why is this wrong?

Explanation

Python is an interpreted language. Source code becomes bytecode, which the Python Virtual Machine interprets.

Q21.

A compiler translates:

Explanation

A compiler translates the entire program into machine code at once and then runs it.

Q22.

How does an interpreter handle errors?

Explanation

An interpreter translates and executes line by line, so it stops as soon as it hits the first error.

Q23.

Which statement comparing compilers and interpreters is correct?

Explanation

Compiled code runs faster because it is already translated; interpreters are slower but make debugging easier.

Q24.

In the translator analogy, an interpreter is like:

Explanation

An interpreter works like a live translator, handling one sentence (statement) at a time.

Q25.

Which is the correct execution flow of a Python program?

Explanation

Source code (.py) is compiled internally to bytecode, which the Python Virtual Machine executes to give the output.

Q26.

What does PVM stand for?

Explanation

PVM is the Python Virtual Machine, which reads and executes bytecode.

Q27.

Which file extension is sometimes used for Python bytecode files?

Explanation

Bytecode is sometimes saved as .pyc files; source code uses .py.

Q28.

What makes Python programs cross-platform?

Explanation

Bytecode is platform-independent; any computer with a PVM can run it, and the PVM deals with the hardware.

Q29.

What is the extension of a Python source file?

Explanation

Python source files use the .py extension.

Q30.

What is the full form of IDLE?

Explanation

IDLE stands for Integrated Development and Learning Environment โ€” the default editor that comes with Python.

Q31.

Which part of IDLE shows the >>> prompt and runs commands immediately?

Explanation

The Python Shell shows the >>> prompt and works in Interactive Mode.

Q32.

What is the IDLE feature that shows keywords, strings and comments in different colours?

Explanation

Syntax colouring displays different parts of the code in different colours, making it easier to read.

Q33.

Which tool is a free Python distribution with many data-science packages pre-installed?

Explanation

Anaconda is a free Python distribution with many data-science packages; Spyder comes with it.

Q34.

Which tool is web-based and lets you write code and see its output in 'cells'?

Explanation

Jupyter Notebook is a web-based tool where code and output appear in cells.

Q35.

What is the >>> symbol in the Python shell called?

Explanation

is the Python prompt (chevron), showing that Python is ready to accept a command in Interactive Mode.

Q36.

In Interactive Mode, what is shown after typing 7 / 2 at the >>> prompt?

Explanation

The / operator performs division, so 7 / 2 gives 3.5.

Q37.

What is the main disadvantage of Interactive Mode?

Explanation

In Interactive Mode the commands are not saved, so they must be retyped; it is not suitable for long programs.

Q38.

How can you leave the Python shell?

Explanation

Typing exit() or quit() leaves the Python shell.

Q39.

In Script Mode, a program is:

Explanation

In Script Mode the complete program is written in the editor, saved as a .py file and executed as a whole.

Q40.

Which key runs a program (Run โ†’ Run Module) in IDLE?

Explanation

Run โ†’ Run Module, or pressing F5, runs the saved program; the output appears in the Python Shell.

Q41.

What is the correct order of steps to run a program in IDLE's Script Mode?

Explanation

Open a new file, type the program, save it as name.py, then run it with Run โ†’ Run Module (F5).

Q42.

A friend typed a long program in the Python shell and wants to run it again tomorrow. What should they do?

Explanation

Shell commands are not saved. Script Mode saves the program as a .py file that can be re-run any time.

Q43.

Interactive Mode is best suited for:

Explanation

Interactive Mode gives instant results, so it is ideal for testing small code and using Python as a calculator.

Q44.

What is the output of this program?

name = "Riya" print("Hello,", name)

Explanation

Items separated by commas are printed with a space between them: Hello, Riya.

Q45.

What is the output of print("5 + 3")?

Explanation

Text inside quotes is printed exactly as it is, so it prints 5 + 3.

Q46.

What is the output of print("Total =", 5 * 3)?

Explanation

5 * 3 is evaluated to 15, and the comma adds a space: Total = 15.

Q47.

What happens when you run Print("Hi")?

Explanation

Python is case-sensitive; Print is not the same as print, so a NameError is raised.

Q48.

When printing text (a string) with print(), the text must be:

Explanation

Strings must be enclosed in single or double quotes, e.g. 'Hi' or "Hi".

Q49.

When multiple items are separated by commas in print(), they are printed:

Explanation

print() separates multiple items with a space.

Q50.

What does Python do with a line that starts with #?

Explanation

Lines starting with # are comments; Python ignores them โ€” they explain the code to humans.

Q51.

What error occurs if a top-level statement starts with an unexpected space?

Explanation

Top-level statements must start at the beginning of the line; an unexpected leading space gives an IndentationError.

Q52.

Which of these Python libraries/tools is used for AI and machine learning?

Explanation

TensorFlow and scikit-learn are used for AI and machine learning.