08074 Python Exam Sample Questions | Generated by AI

Home 2026.03

Question: Provide 50 sample exam questions from past years for the 08074 Advanced Computer Programming exam in the Guangdong National Higher Education Self-study Examination (Computer Science bachelor’s degree).

Answer:

Actual past exam papers (历年真题) for course code 08074 (计算机高级程序设计) in Guangdong self-study exams are not freely and publicly available online in full form (they are often sold in paid question banks, video courses, or official channels). Official Guangdong self-study exam true questions are typically distributed through authorized platforms or bookstores, and many sites indicate “no past questions available” or redirect to purchase.

However, the exam is based on the textbook Python 语言程序设计基础教程 (Fu Qingping et al., Tsinghua University Press, 2022 edition). Exams usually include:

Below are 50 representative sample questions compiled in the typical style and difficulty of this course (covering core chapters: basics, control structures, data types, functions, OOP, files, exceptions, modules, strings/regex, GUI basics, etc.). These are modeled after common self-study exam patterns, simulation tests (模拟题), and textbook exercises for Python-based advanced programming courses.

Multiple Choice / Single Selection (单选题) – 1 point each (approx. 20-30% of exam)

  1. In Python, which of the following is an immutable data type?
    A. list B. dict C. tuple D. set

  2. What is the output of print(3 ** 2 // 4)?
    A. 2 B. 2.25 C. 9 D. 1

  3. Which statement is used to define a function in Python?
    A. function B. def C. func D. define

  4. In object-oriented programming, what does “inheritance” allow?
    A. Code duplication B. A class to inherit attributes and methods from another class C. Data hiding only D. Multiple return values

  5. Which module is commonly used for regular expressions in Python?
    A. os B. sys C. re D. math

  6. What does the with statement primarily handle?
    A. Loops B. Exception handling C. Resource management (e.g., file closing) D. Function definition

  7. Which of the following creates a list comprehension?
    A. [x for x in range(5)] B. {x for x in range(5)} C. (x for x in range(5)) D. {x: x for x in range(5)}

  8. In Python 3, what is the type of input() return value?
    A. int B. str C. float D. list

  9. Which keyword is used to raise an exception manually?
    A. throw B. raise C. except D. try

  10. What is the purpose of __init__ method in a class?
    A. Destructor B. Constructor C. Static method D. Class variable

True/False (判断题) – 1 point each

  1. Python lists are mutable, while tuples are immutable. (True/False)

  2. A function without a return statement returns None by default. (True/False)

  3. In Python, all exceptions must be caught using try-except. (True/False)

  4. The global keyword is required to modify a global variable inside a function. (True/False)

  5. Python supports multiple inheritance. (True/False)

Fill-in-the-Blank (填空题) – 1-2 points each

  1. The method to add an element to the end of a list is __.

  2. To open a file for reading and writing (text mode), use open('file.txt', ____).

  3. The decorator syntax uses the __ symbol before a function definition.

  4. In exception handling, the block that always executes is __.

  5. To generate random integers between 1 and 10, use random.______(1, 10).

Code Analysis / Short Answer (程序阅读或简答题)

  1. What is the output of the following code?
    def func(x, y=5):
        return x * y
    print(func(3))
    print(func(4, 2))
    
  2. Explain the difference between == and is operators in Python.

  3. What will happen if you run this code? (Identify the error)
    try:
        x = 1 / 0
    except:
        print("Error")
    
  4. Describe what a generator function is and give one advantage over a normal list.

  5. Write the output of:
    s = "hello world"
    print(s.capitalize())
    print(s.upper())
    print(s.find("o"))
    

Programming Questions (编程题) – 5-15 points each (often require writing functions or small programs)

  1. Write a function is_prime(n) that returns True if n is a prime number, False otherwise.

  2. Write a function to reverse a string without using slicing ([::-1]).

  3. Write code to read a text file “data.txt” and count the number of words in it.

  4. Define a class Rectangle with attributes length and width, and methods to calculate area and perimeter.

  5. Use list comprehension to create a list of squares of even numbers from 1 to 20.

  6. Write a program that takes user input for a number and prints its factorial using recursion.

  7. Handle file not found exception when opening a file and print a friendly message.

  8. Write a function that takes a list and returns a new list with unique elements only (preserve order).

  9. Use the re module to check if a string is a valid email address (simple pattern).

  10. Create a simple tkinter window with a button that prints “Hello” when clicked.

  11. Write code to sort a list of dictionaries by a key (e.g., sort students by age).

  12. Implement a decorator that measures and prints the execution time of a function.

  13. Read CSV-like data from a file and calculate the average of a numeric column.

  14. Write a recursive function to compute the Fibonacci sequence up to n terms.

  15. Use os module to list all .txt files in the current directory.

  16. Create a class BankAccount with deposit, withdraw, and balance check methods.

  17. Write code to copy contents from one file to another.

  18. Use lambda and map() to convert a list of temperatures from Celsius to Fahrenheit.

  19. Implement bubble sort algorithm for a list of numbers.

  20. Write a program that finds the most frequent word in a text file.

  21. Use try-except-finally to ensure a file is closed after processing.

  22. Define a class hierarchy: Animal → Dog and Cat, with a speak() method overridden.

  23. Write code to serialize a dictionary to a JSON file using json module.

  24. Create a generator that yields Fibonacci numbers indefinitely.

  25. Write a complete small program: Accept student names and scores, store in dict, print sorted by score descending.

These samples cover the main knowledge points tested (basics to advanced Python features). For real past papers or more accurate simulations, refer to Guangdong self-study exam official resources, authorized bookstores, or platforms like zikaosw.cn, Bilibili courses, or Taobao study packs that include true questions and mocks.

References:


Back Donate