MCQz

Python Programming

Computer Science · 11th Class (Intermediate Part 1) · BISE Lahore

70 questions

Tests for this chapter

Tests run in your chosen medium — the sample below shows both.

Full Book Test

20 questions · Introduction to Software Development × 3, Python Programming × 3, Algorithms and Problem Solving × 2, Computational Structures × 2, Data Analytics × 3, Emerging Technologies × 2, Legal and Ethical Aspects of Computing System × 2, Online Research and Digital Literacy × 1, Entrepreneurship in Digital Age × 2

Python Programming Test

10 questions · Python Programming × 10

Sample questions

Showing 20 of 70 questions from this chapter. The full bank is in the chapter test below.

  1. 1

    Which option lists the basic steps of writing a computer program in the correct order?

    • A.Compile or interpret the code, write the code, execute it, then display the output
    • B.Write the code, display the output, translate the code, then execute it
    • C.Write the code, translate it with a compiler or interpreter, execute it, then produce output (correct answer)
    • D.Write the code, execute it, translate it, then display the output
    Why: Writing the instructions comes first, then a translator turns them into a form the computer can run, and only then can the program execute and produce output. Execution cannot happen before translation for a high-level language.
  2. 2

    During program development, what does the execute step mean?

    • A.Running the translated code so that it carries out the intended task (correct answer)
    • B.Saving the source file to the disk
    • C.Checking the source code for spelling mistakes
    • D.Installing an editor on the computer
    Why: Execution is when the computer actually performs the instructions of the program. Saving files, spell-checking and installing tools are preparation steps, not execution.
  3. 3

    Where can the official Python interpreter and standard library be downloaded?

    • A.From any code editor's extension store
    • B.From the Python Package Index only
    • C.From a word processor's website
    • D.From python.org (correct answer)
    Why: The official Python distribution is published at python.org. The Python Package Index hosts third-party packages, not the interpreter itself.
  4. 4

    What does IDE stand for in a Python development setup?

    • A.Internal Debugging Engine
    • B.Integrated Development Environment (correct answer)
    • C.Interactive Data Editor
    • D.Interpreted Development Executable
    Why: An IDE brings an editor, run controls and debugging tools together in one application. The other expansions are invented terms.
  5. 5

    Which installation option makes Python easy to run from the command line?

    • A.Selecting the Add Python to PATH checkbox (correct answer)
    • B.Choosing a custom installation folder
    • C.Installing only the standard library
    • D.Skipping the documentation files
    Why: Adding Python to PATH registers the interpreter's folder with the operating system, so typing the python command works from any directory.
  6. 6

    What does modular programming mean?

    • A.Writing the whole program as one long block of code with no functions
    • B.Running the program one statement at a time to find errors
    • C.Dividing a program into smaller, manageable and reusable pieces called modules (correct answer)
    • D.Storing all the data used by a program in a single list
    Why: Breaking a large program into modules lets separate parts be written, tested and reused independently, which makes the whole project easier to manage. It is a way of organising code, not a way of running it or storing data.
  7. 7

    What happens to a line of Python code that begins with the # symbol?

    • A.It is executed after the rest of the program has finished
    • B.It is ignored by the interpreter and serves as a note for people reading the code (correct answer)
    • C.It is displayed on the screen when the program runs
    • D.It causes a syntax error
    Why: The # symbol starts a single-line comment, which the interpreter skips entirely. Comments exist to explain the code to human readers.
  8. 8

    Which of the following is used to write a comment that spans several lines in Python?

    • A.A line beginning with //
    • B.A pair of round brackets around the text
    • C.A line beginning with <!--
    • D.A block of text enclosed in triple quotes (correct answer)
    Why: Triple-quoted text is the common way to write a multi-line comment in Python. The other markers belong to different languages: // and <!-- --> are not Python comment symbols.
  9. 9

    What is displayed by: age = 25; print("Age:", age)

    • A.25
    • B.Age: 25 (correct answer)
    • C.Age:
    • D.Age:25
    Why: The print function writes each argument in order and separates consecutive arguments with a single space, so the label and the value appear together as Age: 25. Printing age by itself would show only 25.
  10. 10

    Which statement best describes a variable in Python?

    • A.A named storage location in memory whose value can change while the program runs (correct answer)
    • B.A fixed value that cannot be altered once the program starts
    • C.A line of code that is ignored by the interpreter
    • D.A rule that decides the order in which operators are evaluated
    Why: A variable is a named container in memory that allows data to be stored, retrieved and updated. Comments are ignored lines, and operator precedence orders evaluation, so those options describe different ideas.
  11. 11

    Which of the following is a valid Python variable name?

    • A.2nd_score
    • B.total-marks
    • C.total marks
    • D.total_marks (correct answer)
    Why: Names may contain letters, digits and underscores, but they cannot begin with a digit and cannot contain spaces or hyphens.
  12. 12

    In Python, what is the result of running the statement age = 20 and then the statement Age = 25?

    • A.The second assignment overwrites the first, so only one variable exists
    • B.Two separate variables exist, because Python names are case-sensitive (correct answer)
    • C.The program stops with an error, because both names mean the same variable
    • D.Both names hold 25, because Python ignores capital letters
    Why: Case sensitivity makes age and Age different identifiers, so each keeps its own value. No error occurs and neither assignment overwrites the other.
  13. 13

    Which of the following cannot be used as a variable name in Python?

    • A.marks_1
    • B._total
    • C.while (correct answer)
    • D.total2
    Why: while is a reserved keyword that belongs to loop syntax, so it cannot name a variable. The other three names follow the rules for identifiers.
  14. 14

    Which name best follows the recommended Python style for a variable that stores a student's name?

    • A.student_name (correct answer)
    • B.studentName
    • C.StudentName
    • D.student name
    Why: The recommended style uses lowercase letters with underscores between words. A space makes a name illegal, and the capitalised forms simply follow a different convention.
  15. 15

    A variable is assigned the value 19.99. Which built-in data type does it have?

    • A.int
    • B.str
    • C.float (correct answer)
    • D.bool
    Why: A number written with a decimal point is a float. The int type stores whole numbers and bool stores only True or False.
  16. 16

    Which of these values has the data type bool?

    • A."True"
    • B.0
    • C.True (correct answer)
    • D.1
    Why: True is one of the two boolean literals, so its type is bool. The same word inside quotation marks becomes a string, and 0 and 1 are integers.
  17. 17

    What does the input() function give back to the program?

    • A.An integer, whatever the user types
    • B.A float if the user types a decimal number
    • C.The same type as the value entered by the user
    • D.A string of text, which must be converted before it can be used in arithmetic (correct answer)
    Why: input() always returns a string, even when the user types digits. The program must apply int() or float() before doing arithmetic with that value.
  18. 18

    Which statement reads a whole number typed by the user into the variable age?

    • A.age = int(input("Enter your age: ")) (correct answer)
    • B.age = input(int("Enter your age: "))
    • C.age = float(input("Enter your age: "))
    • D.age = str(input("Enter your age: "))
    Why: int() must wrap the string returned by input() so that the typed text is converted into an integer. float() would produce a decimal number and str() would leave the value as text.
  19. 19

    Which built-in function converts text typed by the user into a decimal number such as 1.75?

    • A.str()
    • B.float() (correct answer)
    • C.int()
    • D.bool()
    Why: float() converts a numeric string containing a decimal point into a floating-point number. int() would fail on the decimal point, and str() would leave the value as text.
  20. 20

    What is the value of the expression 10 % 3?

    • A.3.33
    • B.3
    • C.1 (correct answer)
    • D.0
    Why: The % operator gives the remainder of a division: 3 fits into 10 three times with 1 left over. The exact quotient comes from / and the whole-number part from //.
← All chapters of Computer Science