






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























1. What is a script?
A. A sequence of instructions executed by a computer B. A type of hardware component C. A database table D. A network protocol
Correct Answer: A
Rationale: A script is a set of commands written in a programming language that instructs a computer to perform specific tasks.
2. Python is classified as a:
A. High-level programming language B. Machine language C. Assembly language D. Operating system
Correct Answer: A
Rationale: Python is a high-level language designed to be easy to read and write.
3. Which of the following is commonly used to display output in Python?
A. print() B. display() C. output() D. show()
Correct Answer: A
Rationale: The print() function displays information to the screen.
4. Which symbol is used to begin a comment in Python?
A. # B. // C. /* D. &
Correct Answer: A
Rationale: Python uses the hash symbol (#) for single-line comments.
5. What is the purpose of comments in a program?
A. Explain code and improve readability B. Speed up execution C. Store variables D. Create loops
Correct Answer: A
Rationale: Comments help programmers understand and maintain code.
6. Which of the following is a valid variable name in Python?
A. student_name B. 2student C. class D. first-name
Correct Answer: A
Rationale: Variable names cannot start with a number, use hyphens, or reserved keywords.
7. A variable is used to:
A. Store data values B. Execute loops
A. True B. "True" C. 1. D. "Yes"
Correct Answer: A
Rationale: Boolean values are either True or False.
12. What will the following code output?
print(5 + 3)
A. 8 B. 53 C. 5+ D. Error
Correct Answer: A
Rationale: The addition operator calculates the sum of 5 and 3.
13. Which operator performs multiplication?
A. * B. + C. / D. %
Correct Answer: A
Rationale: The asterisk ( ) is used for multiplication. *
14. Which operator performs division?
A. / B. * C. + D. =
Correct Answer: A
Rationale: The forward slash performs division.
15. What is the result of 10 % 3?
A. 1 B. 3 C. 0 D. 10
Correct Answer: A
Rationale: The modulus operator returns the remainder after division.
16. Which operator is used for assignment?
A. = B. == C. != D. >=
Correct Answer: A
Rationale: The assignment operator stores values in variables.
17. Which operator checks equality?
A. == B. = C. += D. //
Correct Answer: A
Rationale: Double equals compares values for equality.
18. What is the purpose of input()?
A. Receive user input B. Print output C. Create loops D. Define variables
Correct Answer: A
Correct Answer: A
Rationale: len() returns the number of items or characters.
23. Which structure allows decisions in a program?
A. if statement B. variable C. string D. comment
Correct Answer: A
Rationale: Conditional statements control program flow.
24. What keyword follows an if statement for an alternative condition?
A. elif B. loop C. switch D. repeat
Correct Answer: A
Rationale: elif allows multiple conditions to be evaluated.
25. Which keyword executes when all previous conditions are false?
A. else B. if C. while D. break
Correct Answer: A
Rationale: else provides a default action.
26. What is the output?
x = 10 if x > 5: print("Yes")
A. Yes B. No C. 10 D. Error
Correct Answer: A
Rationale: Since 10 is greater than 5, the condition evaluates to True.
27. Which comparison operator means "not equal to"?
A. != B. == C. >= D. <=
Correct Answer: A
Rationale: != checks whether values are different.
28. Which logical operator requires both conditions to be true?
A. and B. or C. not D. xor
Correct Answer: A
Rationale: and returns True only if both conditions are true.
29. Which logical operator requires at least one condition to be true?
A. or B. and C. not D. ==
Correct Answer: A
Rationale: The or operator evaluates to True if any condition is true.
34. What does range(5) generate?
A. 0,1,2,3, B. 1,2,3,4, C. 0,1,2,3,4, D. 5 only
Correct Answer: A
Rationale: range(5) starts at 0 and stops before 5.
35. Which statement immediately exits a loop?
A. break B. continue C. stop D. exitloop
Correct Answer: A
Rationale: break terminates loop execution.
36. Which statement skips the current iteration and continues looping?
A. continue B. break C. pass D. stop
Correct Answer: A
Rationale: continue skips remaining code for the current iteration.
37. What is a list in Python?
A. An ordered collection of items B. A conditional statement C. A loop structure D. A data conversion function
Correct Answer: A
Rationale: Lists store multiple values in a single variable.
38. Which symbol is used to define a list?
A. [] B. {} C. () D. <>
Correct Answer: A
Rationale: Square brackets define lists.
39. What is the index of the first item in a list?
A. 0 B. 1 C. - D. 10
Correct Answer: A
Rationale: Python uses zero-based indexing.
40. Which method adds an item to the end of a list?
A. append() B. add() C. insertend() D. push()
Correct Answer: A
Rationale: append() adds a new item to the end of a list.
41. Which method removes an item from a list?
A. remove() B. delete() C. erase() D. clearone()
C. send D. print
Correct Answer: A
Rationale: return provides a result from a function.
46. What is debugging?
A. Finding and fixing program errors B. Installing software C. Creating variables D. Compiling hardware
Correct Answer: A
Rationale: Debugging is the process of identifying and correcting errors.
47. A syntax error occurs when:
A. Code violates language rules B. Logic produces wrong results C. Hardware fails D. Memory is full
Correct Answer: A
Rationale: Syntax errors prevent code from running correctly.
48. A logic error occurs when:
A. The program runs but produces incorrect results B. The code cannot start C. Hardware fails D. Input is missing
Correct Answer: A
Rationale: Logic errors affect program correctness rather than execution.
49. Which tool helps programmers trace program execution?
A. Debugger B. Compiler only C. Database D. Router
Correct Answer: A
Rationale: Debuggers help identify issues and monitor variables during execution.
50. Good scripting practices include:
A. Meaningful variable names and comments B. Avoiding indentation C. Using random variable names D. Eliminating documentation
Correct Answer: A
Rationale: Clear naming conventions and documentation improve readability and maintenance.
51. Which data structure stores key-value pairs in Python?
A. Dictionary B. List C. Tuple D. String
Correct Answer: A
Rationale: Dictionaries store data as key-value pairs, allowing fast lookups by key.
52. Which symbol is used to define a dictionary?
A. {} B. [] C. () D. <>
Correct Answer: A
Rationale: Curly braces are used to create dictionaries in Python.
53. What is the output of len([1, 2, 3, 4])?
57. What is the result of type(3.14)?
A. float B. int C. string D. boolean
Correct Answer: A
Rationale: Decimal numbers are stored as floating-point values.
58. Which statement opens a file for reading?
A. open("file.txt", "r") B. open("file.txt", "w") C. open("file.txt", "a") D. open("file.txt", "x")
Correct Answer: A
Rationale: The "r" mode opens a file for reading.
59. Which file mode overwrites an existing file?
A. w B. r C. a D. read
Correct Answer: A
Rationale: Writing mode replaces existing content.
60. Which file mode appends data to the end of a file?
A. a B. r C. w D. x
Correct Answer: A
Rationale: Append mode adds content without deleting existing data.
61. Which method reads an entire file?
A. read() B. write() C. append() D. close()
Correct Answer: A
Rationale: read() retrieves all file contents.
62. Why should files be closed after use?
A. To release system resources B. To increase variable storage C. To improve syntax D. To create loops
Correct Answer: A
Rationale: Closing files ensures resources are properly freed.
63. Which statement is commonly used for automatic file handling?
A. with B. while C. break D. append
Correct Answer: A
Rationale: The with statement automatically closes files after use.
64. What is an exception?
A. An error that occurs during program execution B. A variable name C. A comment block D. A loop counter
Correct Answer: A
Correct Answer: A
Rationale: Division by zero is not mathematically valid and triggers ZeroDivisionError.
69. Which error occurs when using an undefined variable?
A. NameError B. IndexError C. ValueError D. RuntimeError
Correct Answer: A
Rationale: Python cannot locate variables that have not been defined.
70. Which error occurs when accessing a list index that does not exist?
A. IndexError B. NameError C. TypeError D. SyntaxError
Correct Answer: A
Rationale: Invalid list positions produce an IndexError.
71. What is pseudocode?
A. A plain-language description of program logic B. Executable Python code C. Hardware instructions D. Database design
Correct Answer: A
Rationale: Pseudocode helps programmers plan solutions before coding.
72. A flowchart is used to:
A. Visually represent program logic B. Store variables
C. Execute code D. Create databases
Correct Answer: A
Rationale: Flowcharts illustrate steps and decisions in a process.
73. Which flowchart symbol typically represents a decision?
A. Diamond B. Rectangle C. Oval D. Circle
Correct Answer: A
Rationale: Diamonds represent decision points.
74. Which flowchart symbol represents a process?
A. Rectangle B. Diamond C. Oval D. Arrow
Correct Answer: A
Rationale: Rectangles represent actions or operations.
75. Which flowchart symbol usually indicates start or end?
A. Oval B. Rectangle C. Diamond D. Square
Correct Answer: A
Rationale: Ovals indicate the beginning or end of a process.
76. What is algorithm design?