Python Intermediate Exam - October 2023
5 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What does the pass statement do in a for loop during iteration?

  • Outputs an error message when executed.
  • Does nothing for specific iterations while continuing. (correct)
  • Terminates the loop immediately.
  • Skips the current iteration and continues to the next one.
  • Which statement correctly calculates the total amount after reducing a price by 25%?

  • total = price / 0.25
  • total = price * 0.25
  • total = price + (price * 0.25)
  • total = price - (price * 0.25) (correct)
  • In sorting a list of people by age, what should be done if two people share the same age?

  • Print them in the order they were inputted. (correct)
  • Display the older person first.
  • Randomly shuffle their order.
  • Sort them alphabetically by their first names.
  • What is the effect of the continue statement in a loop that iterates through a list of strings?

    <p>It skips the string with the specified condition and continues with the next.</p> Signup and view all the answers

    What data should be collected for each person in the directory program?

    <p>First name, last name, age, and sex.</p> Signup and view all the answers

    Study Notes

    Python Intermediate Exam - October 2023 (CRBS)

    • Question Paper Code: QPCB12
    • Total Marks: 100
    • Total Time: 3 hours

    Section A (Marks: 15 x 2 = 30)

    • Question 1: Write a program using a for loop that prints numbers 1 to 10. Use a pass statement to do nothing for numbers 3 and 7.
    • Question 2: Create a program that iterates through a list of strings. Use a continue statement to skip any string containing the letter 'a'.

    Section B (Marks: 30)

    • Question 3: Develop a program for a restaurant. Users input item prices. Calculate the total amount after a 25% discount.

    Section C (Marks: 40)

    • Question 4: Build a directory of information about N people. User input required for N, names, ages, and sex for each person.
      • Sort ages in ascending order.
      • Names should be printed accordingly, with the youngest first.
      • If two people have the same age, print in the input order.
    • Constraints: 2 ≤ N ≤ 9
    • Sample Input: Number of people, followed by name, age, sex for each person. Example: John, Doe, 25, Male.
    • Sample Output: Sorted names by age, followed by age and sex in parenthesis. Output should look similar to Bob Brown (20, Male).

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    Test your knowledge with this Intermediate Python exam focused on loops, list iteration, and user input handling. It covers topics such as using control statements and organizing data structures efficiently. Perfect for students looking to assess their understanding of Python concepts.

    More Like This

    Use Quizgecko on...
    Browser
    Browser