0% found this document useful (0 votes)
9 views36 pages

Python Programming & Algorithm Basics

The document consists of a comprehensive set of programming questions and answers focused on Python, algorithms, data types, variables, strings, conditional statements, loops, and factorials. It includes multiple-choice questions, true/false questions, fill-in-the-blanks, and matching exercises to test knowledge on these topics. Additionally, it covers both short and long answer questions aimed at deepening understanding of Python programming concepts.

Uploaded by

atieno.rubeni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views36 pages

Python Programming & Algorithm Basics

The document consists of a comprehensive set of programming questions and answers focused on Python, algorithms, data types, variables, strings, conditional statements, loops, and factorials. It includes multiple-choice questions, true/false questions, fill-in-the-blanks, and matching exercises to test knowledge on these topics. Additionally, it covers both short and long answer questions aimed at deepening understanding of Python programming concepts.

Uploaded by

atieno.rubeni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PROGRAMMING QUESTIONS

Set1
Introduction to Programming & Python
(Answer briefly)
1. What is programming?
2. Define Python programming language.
3. State any four features of Python.
4. Why is Python considered a beginner-friendly language?
5. Mention any four applications of Python.
6. What is meant by an interpreted language?
7. Differentiate between Python 2 and Python 3.
8. What is a Python interpreter?
9. Explain the importance of indentation in Python.
10. Write the output of:
print("Hello Python")

Introduction to Algorithms
(Answer briefly)
11. Define an algorithm.
12. State any four characteristics of a good algorithm.
13. Why are algorithms important in programming?
14. Write an algorithm to add two numbers.
15. Differentiate between an algorithm and a program.
16. What is pseudocode?
17. List any three ways of representing an algorithm.
18. Explain the term finiteness in algorithms.
19. What is a flowchart?
20. Identify the symbols used for input/output and decision in a flowchart.

Data Types (Algorithm & Programming)


(Answer briefly)
21. Define data type.
22. List five data types used in algorithms.
23. What is the difference between INTEGER and REAL data types?
24. Define BOOLEAN data type with examples.
25. What is an array in algorithms?
26. List five built-in data types in Python.
27. Differentiate between list and tuple in Python.
28. What is the use of a dictionary in Python?
29. What is None in Python?
30. Why are data types important in programming?

Variables
(Answer briefly)
31. What is a variable?
32. State the rules for naming variables in Python.
33. Differentiate between variable declaration in algorithms and Python.
34. What is variable assignment?
35. Explain multiple assignment with an example.
36. What is variable reassignment?
37. Define variable scope.
38. Differentiate between local and global variables.
39. What is a constant? How is it represented in Python?
40. What are mutable and immutable data types?

Strings
(Answer briefly)
41. Define a string.
42. How are strings created in Python?
43. Explain string indexing with an example.
44. What is string slicing?
45. Why are strings called immutable?
46. What is string concatenation?
47. List any five string methods.
48. What is string formatting?
49. Explain escape characters with examples.
50. What is the difference between split() and join()?

Conditional Statements
(Answer briefly)
51. What are conditional statements?
52. Explain the syntax of an if statement.
53. Differentiate between if–else and if–elif–else.
54. List all comparison operators in Python.
55. What are logical operators?
56. Explain nested if statements.
57. What are truthy and falsy values?
58. Explain the ternary operator.
59. Identify the error:
if x = 5:
print(x)
60. Why is indentation important in conditional statements?

Loops, Incrementation & Factorial


(Answer briefly)
61. What is incrementation?
62. Why does Python not support ++ operator?
63. How is incrementation done in Python?
64. What is a loop?
65. Differentiate between for loop and while loop.
66. Define factorial of a number.
67. Write the mathematical formula for factorial.
68. Why is factorial not defined for negative numbers?
69. Mention any two applications of factorial in computing.
70. What will be the output of:
n=3
fact = 1
for i in range(1, n+1):
fact *= i
print(fact)

Long Answer / Essay Questions


71. Explain Python programming language in detail.
72. Describe algorithms and their characteristics with examples.
73. Discuss data types in algorithms and Python with a comparison table.
74. Explain variables in Python, including scope and mutability.
75. Explain string handling in Python with examples.
76. Explain conditional statements with suitable examples.
77. Write an algorithm and Python program to calculate the factorial of a number.
78. Explain common errors made by beginners in Python.
79. Discuss the relationship between algorithms and programming languages.
80. Why is problem solving important before writing a program?

MULTIPLE CHOICE QUESTIONS (MCQs)


Introduction to Programming & Python
1. Python is a ______ level programming language.
A. Low
B. Machine
C. High
D. Assembly
2. Python was created by:
A. Dennis Ritchie
B. James Gosling
C. Guido van Rossum
D. Bjarne Stroustrup
3. Python programs are executed by a:
A. Compiler
B. Assembler
C. Interpreter
D. Loader
4. Which of the following is NOT a feature of Python?
A. Easy syntax
B. Platform dependent
C. Open source
D. Large library
5. Which symbol is used for comments in Python?
A. //
B. <!-- -->
C. #
D. /* */

Algorithms
6. An algorithm must always:
A. Run forever
B. Have input only
C. Produce output
D. Be written in Python
7. Which of the following is NOT a characteristic of an algorithm?
A. Finiteness
B. Ambiguity
C. Effectiveness
D. Definiteness
8. An algorithm is ______ independent.
A. Machine
B. Language
C. Platform
D. Hardware
9. Which representation uses symbols and arrows?
A. Pseudocode
B. Program
C. Flowchart
D. Compiler
10. The diamond symbol in a flowchart represents:
A. Input
B. Output
C. Process
D. Decision

Data Types
11. Which data type stores whole numbers?
A. REAL
B. STRING
C. INTEGER
D. BOOLEAN
12. Which Python data type stores key–value pairs?
A. List
B. Tuple
C. Dictionary
D. Set
13. TRUE and FALSE belong to which data type?
A. Integer
B. Boolean
C. String
D. Float
14. Which data type is mutable in Python?
A. int
B. str
C. tuple
D. list
15. Which represents “no value” in Python?
A. 0
B. False
C. None
D. Empty string

Variables
16. A variable is used to:
A. Store instructions
B. Store data
C. Store comments
D. Store errors
17. Which is a valid Python variable name?
A. 2value
B. value-2
C. _value
D. class
18. Python variables are:
A. Statically typed
B. Dynamically typed
C. Untyped
D. Machine typed
19. Which keyword is used to define constants in Python?
A. const
B. final
C. static
D. None (no keyword)
20. Which variable scope is accessible throughout the program?
A. Local
B. Block
C. Global
D. Temporary

Strings
21. Strings in Python are enclosed in:
A. Brackets
B. Curly braces
C. Quotes
D. Parentheses
22. Indexing in Python strings starts from:
A. 1
B. -1
C. 0
D. Any number
23. Strings in Python are:
A. Mutable
B. Immutable
C. Changeable
D. Dynamic
24. Which method converts text to uppercase?
A. upper()
B. lower()
C. capitalize()
D. title()
25. Which operator joins two strings?
A. *
B. +
C. %
D. &

Conditional Statements
26. Which keyword is used for decision making?
A. loop
B. switch
C. if
D. def
27. Which operator checks equality?
A. =
B. ==
C. !=
D. <=
28. Which logical operator means BOTH conditions must be true?
A. OR
B. NOT
C. AND
D. XOR
29. Which is the correct Python conditional syntax?
A. if x > 5 then
B. if (x > 5)
C. if x > 5:
D. if x > 5 {}
30. Which value is considered FALSE in Python?
A. "Hello"
B. 1
C. []
D. "0"

Incrementation & Factorial


31. Which operator is used for incrementation in Python?
A. ++
B. +=
C. **
D. //
32. Factorial of 0 is:
A. 0
B. 1
C. Undefined
D. Error
33. Factorial is represented by the symbol:
A. %
B. *
C. !
D. #
34. Factorial can be calculated using:
A. Condition only
B. Loop or recursion
C. Strings
D. Dictionaries
35. Which loop is best suited when the number of iterations is known?
A. while
B. for
C. do-while
D. repeat

TRUE / FALSE QUESTIONS


36. Python supports the ++ operator. (True/False)
37. Algorithms must terminate after a finite number of steps. (True/False)
38. Strings in Python can be modified after creation. (True/False)
39. Python is a compiled language only. (True/False)
40. Lists are mutable in Python. (True/False)
41. Boolean data type has only two values. (True/False)
42. Indentation is optional in Python. (True/False)
43. Variables must be declared before use in Python. (True/False)
44. A flowchart helps visualize program logic. (True/False)
45. Factorial is defined for negative numbers. (True/False)
FILL IN THE BLANKS
46. Python is an __________ programming language.
47. An algorithm is a __________ step-by-step procedure.
48. The data type used to store text is __________.
49. The symbol used for comments in Python is __________.
50. The first index of a string is __________.
51. The operator used to compare equality is __________.
52. The factorial of 5 is __________.
53. Variables store data in __________.
54. TRUE and FALSE belong to the __________ data type.
55. The decision symbol in a flowchart is __________.

MATCH THE FOLLOWING

Column A Column B
56. INTEGER a. True / False
57. STRING b. Whole numbers
58. BOOLEAN c. Sequence of characters
59. LIST d. Mutable collection
60. IF e. Decision making

ANSWES
Introduction to Programming & Python

1. Python is a high level programming language. → C


2. Python was created by Guido van Rossum. → C
3. Python programs are executed by an interpreter. → C
4. Which of the following is NOT a feature of Python? → B Platform dependent
5. Which symbol is used for comments in Python? → C #

Algorithms

6. An algorithm must always produce output. → C


7. Which of the following is NOT a characteristic of an algorithm? → B Ambiguity
8. An algorithm is language independent. → B
9. Which representation uses symbols and arrows? → C Flowchart
10. The diamond symbol in a flowchart represents decision. → D

Data Types
11. Which data type stores whole numbers? → C INTEGER
12. Which Python data type stores key–value pairs? → C Dictionary
13. TRUE and FALSE belong to which data type? → B Boolean
14. Which data type is mutable in Python? → D list
15. Which represents “no value” in Python? → C None

Variables

16. A variable is used to store data. → B


17. Which is a valid Python variable name? → C _value
18. Python variables are dynamically typed. → B
19. Which keyword is used to define constants in Python? → D None (no keyword)
20. Which variable scope is accessible throughout the program? → C Global

Strings

21. Strings in Python are enclosed in quotes. → C


22. Indexing in Python strings starts from 0. → C
23. Strings in Python are immutable. → B
24. Which method converts text to uppercase? → A upper()
25. Which operator joins two strings? → B +

Conditional Statements

26. Which keyword is used for decision making? → C if


27. Which operator checks equality? → B ==
28. Which logical operator means BOTH conditions must be true? → C AND
29. Which is the correct Python conditional syntax? → C if x > 5:
30. Which value is considered FALSE in Python? → C []

Incrementation & Factorial

31. Which operator is used for incrementation in Python? → B +=


32. Factorial of 0 is 1. → B
33. Factorial is represented by the symbol ! → C
34. Factorial can be calculated using loop or recursion → B
35. Which loop is best suited when the number of iterations is known? → B for
TRUE / FALSE

36. Python supports the ++ operator. → False


37. Algorithms must terminate after a finite number of steps. → True
38. Strings in Python can be modified after creation. → False
39. Python is a compiled language only. → False
40. Lists are mutable in Python. → True
41. Boolean data type has only two values. → True
42. Indentation is optional in Python. → False
43. Variables must be declared before use in Python. → False
44. A flowchart helps visualize program logic. → True
45. Factorial is defined for negative numbers. → False

FILL IN THE BLANKS

46. Python is an high-level programming language.


47. An algorithm is a finite step-by-step procedure.
48. The data type used to store text is string.
49. The symbol used for comments in Python is #.
50. The first index of a string is 0.
51. The operator used to compare equality is ==.
52. The factorial of 5 is 120.
53. Variables store data in memory.
54. TRUE and FALSE belong to the Boolean data type.
55. The decision symbol in a flowchart is diamond.

MATCH THE FOLLOWING

56. INTEGER → b. Whole numbers


57. STRING → c. Sequence of characters
58. BOOLEAN → a. True / False
59. LIST → d. Mutable collection
60. IF → e. Decision making

Set2
Section 1: Python Introduction & Basics (1-15)
1. What are the three primary features that make Python "high-level"?
2. True/False: Python is a compiled language like C++.
3. Which function is used to display output to the console?
4. List three real-world applications of Python.
5. What is the difference between an .py file and the Python interpreter?
6. Who created Python?
7. True/False: Python is case-sensitive (e.g., Variable and variable are different).
8. What is the purpose of a "comment" in code?
9. Which symbol is used for single-line comments?
10. Describe the "indentation" rule in Python syntax.
11. What happens if you use a Python "Keyword" as a variable name?
12. How do you check the version of Python installed on a system?
13. Name two advantages of Python over other languages.
14. Name two limitations of Python.
15. What is the purpose of the input() function?

Section 2: Algorithms & Logic (16-30)


16. Define an "Algorithm" in your own words.
17. List three characteristics of a "good" algorithm.
18. Scenario: Write an algorithm for making a cup of tea.
19. What is "Pseudocode" and how does it differ from actual code?
20. In a flowchart, what does a Diamond shape represent?
21. In a flowchart, what does a Rectangle shape represent?
22. What is the difference between an algorithm and a program?
23. Why is "Finiteness" important in algorithm design?
24. Give an example of a "Real-life Algorithm."
25. Describe "Plain English" representation of an algorithm.
26. What makes an algorithm "efficient"?
27. List two properties of a "Bad Algorithm."
28. How does an algorithm relate to problem-solving?
29. True/False: An algorithm must always have at least one input.
30. Explain the "Input-Process-Output" model.

Section 3: Data Types (31-45)


31. What is the Python keyword for an integer?
32. What is the difference between a float and an int?
33. Which data type represents text?
34. A bool can only have two values. What are they?
35. How do you define a List in Python? (Which brackets?)
36. What is the NoneType used for?
37. True/False: A list can contain different data types (e.g., an int and a string).
38. What is the data type of "123"?
39. What is the data type of 123.0?
40. Why are data types important in programming?
41. Which data type is used to store a collection of unique items?
42. How does a Tuple differ from a List visually (syntax)?
43. What is a "Mapping" data type? (Hint: Key-Value pairs).
44. Name a common mistake beginner make with data types.
45. How do you check the type of a variable in Python?
Section 4: Variables & Memory (46-65)
46. What is a "Variable" in terms of computer memory?
47. List three rules for naming variables in Python.
48. Valid or Invalid: 2_my_var?
49. Valid or Invalid: my_var_2?
50. How do you assign the value 10 to three variables (a, b, c) in one line?
51. Explain "Variable Re-assignment."
52. What is "Type Casting"?
53. Convert the string "25" to an integer.
54. What is the result of x = 5; x += 2?
55. Describe the difference between a Local and Global variable.
56. What is a "Constant" and how is it usually named in Python?
57. Explain the concept of "Memory References."
58. What does "Mutable" mean?
59. Name two Mutable data types.
60. Name two Immutable data types.
61. What happens to the original value if you "change" a string?
62. Short Answer: Why are Tuples faster than Lists?
63. Explain the error: UnboundLocalError.
64. How do you delete a variable from memory?
65. What is the "naming convention" for multi-word variables (e.g., snake_case)?

Section 5: Strings (66-80)


66. How do you create a multi-line string?
67. What is "String Indexing"?
68. If s = "Hello", what is s[0]?
69. What is "String Slicing"?
70. Given word = "Python", how do you get "tho"?
71. What does the len() function do?
72. How do you join two strings together?
73. What is "String Repetition"? (e.g., "Ha" * 3)
74. Name three built-in string methods (e.g., .upper()).
75. What is an "Escape Character"? Give an example.
76. How do you check if a word exists inside a string?
77. Explain "f-strings" (Formatted strings).
78. What does the .split() method do?
79. What does the .strip() method do?
80. True/False: Strings are mutable.

Section 6: Conditional Statements (81-100)


81. What is the purpose of an if statement?
82. When is an else block executed?
83. What does elif stand for?
84. Write the symbol for "Equal to" in a comparison.
85. Write the symbol for "Not equal to."
86. What is the result of (5 > 3) and (2 > 4)?
87. What is the result of (5 > 3) or (2 > 4)?
88. What is a "Nested IF" statement?
89. Describe "Indentation Error" in the context of IF statements.
90. What is a "Truthy" value? Give an example.
91. List three "Falsy" values in Python.
92. What is a "Ternary Operator"?
93. Rewrite this in one line: if a > b: max = a; else: max = b.
94. Why is the : (colon) important in an IF statement?
95. How do you check if a value is NOT in a list?
96. Scenario: Write an IF statement that checks if a number is between 1 and 10.
97. What is the difference between = and ==?
98. What happens if no conditions in an if-elif chain are met and there is no else?
99. Logic: Can you have an elif without an if?
100. Write a small program that takes a score (0-100) and prints "Pass" if 50 or above.

I. Algorithms & Computational Logic (Questions 1-20)


1. Efficiency Paradox: Given two algorithms for the same task, why might a "Good Algorithm" with
more steps be preferred over a shorter one if the shorter one has high "Space Complexity"?
2. Pseudocode Logic: Write a pseudocode for a "Bubble Sort" logic. How does it satisfy the
"Finiteness" property?
3. Flowchart Architecture: Design a flowchart for a system that requires a "Nested Loop." How do
you represent the return to the inner loop vs. the outer loop?
4. Algorithm vs Program: Prove with an example why an algorithm is "Logical" while a program is
"Implementation."
5. Real-life Algorithm failure: Describe a real-life algorithm (like a recipe) that lacks "Definiteness."
What is the consequence?
6. Comparison: Contrast "Plain English" and "Pseudocode." In what technical scenario would Plain
English fail but Pseudocode succeed?
7. Algorithmic Relationship: Explain how the choice of a Data Structure (like a Set vs a List) can
fundamentally change the "Characteristics" of an algorithm.
8. Edge Case Logic: Develop an algorithm for a login system. List 3 "Bad Algorithm" properties it
would show if it didn't handle empty inputs.
9. Flowchart Symbols: Why is a "Decision Box" the only symbol in a flowchart that allows for two
exit paths?
10. Problem Solving: Translate a complex word problem (e.g., calculating compound interest) into a
10-step pseudocode.
11. Scalability: If an algorithm works for 10 items but crashes at 10,000, which "Characteristic of a
Good Algorithm" did it fail?
12. Logic Flow: Can a flowchart have multiple "Start" or "End" points? Justify your answer based on
"Finiteness."
13. Optimization: Take a 15-step algorithm and reduce it to 8 steps without losing "Input/Output"
accuracy.
14. Programming Algorithm: Explain the logic of a "Search" algorithm using only Python syntax
basics.
15. Bad Algorithm Analysis: Critically analyze an algorithm that contains a "Circular Dependency."
16. Ways to Represent: Why is a Flowchart better for visual learners but Pseudocode better for
developers?
17. Real-world Logic: How does a traffic light system demonstrate "Condition-based" algorithms?
18. Binary Logic: Represent a "Yes/No" decision tree using only if and else pseudocode.
19. Algorithm Importance: Why is the "Algorithm" phase the most expensive part of software
development?
20. Relationship: How does a "Variable" act as a container within a Flowchart's "Process" box?

II. Data Types & Memory Mechanics (Questions 21-40)


21. Memory Addressing: If x = 10, explain why changing x = 20 doesn't "change" the number 10 in
memory but reassigns the label.
22. Type Precision: Why does 0.1 + 0.2 == 0.3 return False in Python? Relate this to the Float data
type.
23. List vs Array: In your notes, you equated List to Array. Explain why a Python List is more complex
because it can hold "Heterogeneous" data.
24. NoneType Logic: In an algorithm, why would you initialize a variable to None instead of 0 or ""?
25. Structural Mapping: How does a Dictionary (Key-Value) optimize search time compared to
a List?
26. Immutability Conflict: Why can a Tuple be used as a Dictionary key, but a List cannot?
27. Boolean Arithmetic: What is the result of (True + True) * False? Explain why Python allows this
math.
28. None vs Null: Compare Python's NoneType to the concept of Null in Algorithms.
29. Set Theory: Explain the algorithmic advantage of a Set when you need to find "Unique" values in
a dataset of 1 million items.
30. Type Checking: Why is type(x) == int less "Pythonic" than isinstance(x, int)?
31. Float Conversion: What happens when you convert float(1e308)? Explain the concept of
"Infinity" in Python.
32. Integer Limits: Unlike C++, Python integers have "Arbitrary Precision." What does this mean for
large algorithms?
33. Character vs String: Python doesn't have a "Char" type. How does this affect the memory usage
of a single letter?
34. Boolean Truthiness: Why is an empty list [] considered False in a conditional statement?
35. Data Structure Importance: Choose the best data type from your notes for a "High-speed
lookup table" and justify it.
36. Complex Conversion: Explain the result of bool("False"). Why is it True?
37. Memory References: If L1 = [1, 2] and L2 = L1, why does [Link](3) change L1?
38. Type Error Analysis: Why does '3' + 3 fail, but '3' * 3 succeed?
39. NoneType Membership: Can None be a value inside a List? What are the implications for an
algorithm?
40. Mistake Analysis: Why is "forgetting to convert input to int" the most common beginner
mistake?

III. Variables & Scope (Questions 41-60)


41. Dynamic Typing: How does Python's "Variables" section differ from "Static Typing" where you
must declare int x?
42. Multiple Assignment: In the statement x, y = y, x, explain the "Under the hood" logic of how
Python swaps these without a third variable.
43. Pointer Aliasing: Explain the concept of "Reference Counting" using the a=10, b=a example from
your notes.
44. Global vs Local: What happens if a function tries to modify a global variable without
the global keyword?
45. Naming Collision: Why shouldn't you name a variable list or str?
46. Memory Efficiency: Which is more memory-efficient: x = x + 1 or x += 1?
47. Variable Scope Leakage: Does a variable defined inside an if block stay alive after the block
ends?
48. Constants: Since Python has no "real" constants, how do developers simulate "Immutability" for
variables?
49. Mutable Default Arguments: Why is it dangerous to use a List as a default value in a function?
50. Garbage Collection: When does a variable's memory actually get freed?
51. Reference Leak: Trace the memory in: a = [1], a = [2]. What happened to [1]?
52. Scope Resolution: Explain the LEGB rule (Local, Enclosing, Global, Built-in).
53. Deep vs Shallow Copy: How do you copy a list so that changes to the copy don't affect the
original?
54. Expression Evaluation: In x = 5 + 2 * 3, which variable "concept" is used to determine the order?
55. Variable Initialization: Why does Python throw a NameError if you try x += 1 before defining x?
56. Shadowing: Explain "Variable Shadowing" when a local variable has the same name as a global
one.
57. Reference equality: Explain the difference between == and is.
58. Large Data: How does [Link]() help in analyzing variable memory?
59. Naming Conventions: Why is camelCase discouraged in Python variables in favor of snake_case?
60. Input/Output Logic: Explain how print(f"{x=}") (Python 3.8+) assists in debugging variables.

IV. Strings & Manipulation (Questions 61-80)


61. Indexing Paradox: Why does s[-1] return the last character? Explain the "Negative Indexing"
algorithm.
62. Slicing Mechanics: Predict the output of "Python"[1:5:2] and explain the step parameter.
63. Immutability Proof: If I do s = "Hello"; s = "J" + s[1:], have I mutated the string or created a new
one?
64. Concatenation Performance: Why is "".join(list) faster than using + in a loop?
65. F-String Security: Compare f-strings to .format(). Which is more readable for complex
expressions?
66. Escape Character Logic: How do you print the literal string \n without creating a newline?
67. Membership Algorithms: How does the in operator work under the hood for a string?
68. String Methods: Difference between .find() and .index() when the character doesn't exist?
69. Encoding: How does Python's str type handle Unicode (emojis)?
70. Slicing Boundaries: Why doesn't "Hello"[1:100] throw an error?
71. Repetition Memory: What happens in memory when you run "A" * 1000000?
72. Split/Join Inverse: Prove that "".join([Link]()) doesn't always return the original string.
73. Triple Quotes: When should you use """ over \n?
74. Case Folding: Difference between .lower() and .casefold() for international strings?
75. Strip vs Replace: Which method is better for removing all spaces, not just leading/trailing?
76. Formatting Precision: How do you format a float inside an f-string to exactly 2 decimal places?
77. String Interning: Why does a = "hi"; b = "hi"; a is b sometimes return True?
78. Boolean Strings: Why does "0" evaluate to True but the integer 0 evaluate to False?
79. Comparison: How are strings compared? (Explain Lexicographical order/ASCII values).
80. Looping: How do you loop through a string to print only the vowels?

V. Conditionals & Control Flow (Questions 81-100)


81. Short-Circuiting: In if A or B:, if A is True, does B ever run? Why is this important for
performance?
82. Nested IF vs ELIF: When is a "Nested IF" required instead of a flat elif chain?
83. Ternary Complexity: Write a nested ternary operator for: If x > 10 "Big", else if x > 5 "Mid", else
"Small".
84. Logic Gates: How do you simulate an XOR gate using only if, and, and or?
85. Truthy/Falsy Deep-dive: Is if [0]: True or False? Explain based on collection rules.
86. Comparison Chaining: Explain how Python evaluates 1 < x < 10.
87. The Walrus Operator: How does if (n := len(x)) > 5: optimize a conditional?
88. Indentation Significance: How does Python's "Off-side rule" (indentation) prevent the "Dangling
Else" problem found in C++?
89. Logical Negation: Is if not x > 5: the same as if x <= 5:? Explain using De Morgan’s Laws.
90. Identity vs Equality: In a conditional, why should you use if x is None: instead of if x == None:?
91. Input Validation: Write a conditional block that checks if a string is a digit AND is an even
number without crashing.
92. Complexity: Why are deep "Nested IFs" considered a "Bad Algorithm" property?
93. Boolean Evaluation: Predict the output of if True or False and False:. (Explain operator
precedence).
94. User Input Logic: Why must we convert input() to a specific type before using comparison
operators like >?
95. The in Operator: How do you use if to check if a key exists in a dictionary vs. a value?
96. Empty State Logic: Why is if my_list: more "Pythonic" than if len(my_list) > 0:?
97. Switch-Case: Python didn't have switch until recently. How did developers use "Dictionaries" to
simulate it?
98. Operator Precedence: Does not have higher priority than and?
99. Structural Pattern Matching: (Advanced) Briefly explain how match-case (Python 3.10+) differs
from if-elif.
100. Final Integration: Design a conditional that checks if a variable is a String, has a length >
5, and starts with a capital letter.

Set3
Section 1: Advanced Algorithms & Computational Logic
1. Complexity Analysis: Compare an algorithm with $O(n)$ complexity vs $O(n^2)$. Which
"Characteristic of a Good Algorithm" dictates this choice for big data?
2. Logic Synthesis: Design a pseudocode for a "Binary Search" logic. Why is it more efficient than a
linear search?
3. Flowchart Optimization: How would you represent a "Recursive" process in a standard
flowchart?
4. Edge Case Testing: Given an algorithm that divides $A$ by $B$, list three "Properties of a Bad
Algorithm" it might exhibit if $B=0$ isn't handled.
5. State Management: In a flowchart, how do you distinguish between a "Process" that changes a
variable and a "Decision" that reads it?
6. Heuristics: Is a "Heuristic" considered a "Good Algorithm" if it doesn't guarantee a perfect
solution but is fast?
7. Algorithm vs Program: Explain why an algorithm can be "Language Agnostic" while a program is
bound by syntax.
8. Deadlock Identification: Create a pseudocode scenario where two algorithms waiting for each
other create a "circular dependency."
9. Branching Logic: How many unique paths exist in a nested decision tree with 3 levels of if-else?
10. Data Flow: Trace the "Relationship between algorithm and data structures." Why can't you have
a good algorithm without an appropriate data type?

Section 2: Memory Architecture & Variable Deep-Dive


11. Object Identity: Explain why x = [1, 2] and y = [1, 2] result in x == y being True, but x is y being
False.
12. Pointer Aliasing: If a = [10], b = a, and [Link](20), why is a now [10, 20]? Describe the
memory reference.
13. Immutability Overhead: In Python, why does "changing" a string actually create a new object in
memory?
14. Interning: Explain "String Interning." Why might a = "hello" and b = "hello" sometimes point to
the exact same memory address?
15. Scope Leakage: If a variable is declared in an if block, is it accessible outside that block in
Python? (Contrast this with other languages).
16. Dynamic Typing Risks: What are the "Limitations of Python" regarding memory safety when a
variable changes from an int to a list?
17. Garbage Collection: What happens to the memory reference of x = 10 when you re-assign x =
20?
18. Constants in Practice: Since Python doesn't have true constants, how does the "Naming
Convention" prevent logical errors in large teams?
19. Deep vs Shallow Copy: Explain the difference when copying a "Nested List."
20. Namespace Analysis: How does Python resolve a variable name if it exists in both Local, Global,
and Built-in scopes?

Section 3: Data Types & Structural Mechanics


21. Heterogeneous Collections: Why is a List in Python technically an array of pointers rather than a
contiguous block of raw data?
22. Tuple Integrity: Prove how a Tuple can be used as a Dictionary "Key," but a List cannot.
23. Hashability: Explain why Mutable types are generally unhashable.
24. Boolean Arithmetic: Evaluate: True + True - False. Why does Python allow math on Booleans?
25. Floating Point Precision: Explain why 0.1 + 0.2 == 0.3 evaluates to False in Python.
26. NoneType Logic: How does if x is None: differ from if x == None:?
27. Bitwise Operations: How do Integers behave at the bit level when using the & or | operators?
28. Set Theory: Use Python Sets to solve a problem involving finding "Common unique visitors"
between two large logs.
29. Dict Efficiency: Explain the $O(1)$ lookup time of a Dictionary vs $O(n)$ of a List.
30. Type Conversion Failures: Under what specific conditions will int(float_string) fail?

Section 4: Advanced String Manipulation & Formatting


31. Unicode Mastery: How does Python handle Emojis in string length vs standard ASCII characters?
32. Slice Step Logic: Predict the output of "Python"[::-1] and explain the underlying algorithm of the
negative step.
33. Memory View: What is the advantage of using a memoryview on a large string buffer?
34. Template Security: Why is f-string more "efficient" than .format() or % formatting?
35. Join vs Concat: Prove why ''.join(list_of_strings) is $O(n)$ while using + in a loop is $O(n^2)$.
36. Escape Character Collisions: How do "Raw Strings" (r"") solve the problem of Windows file
paths?
37. Immutability Workarounds: If you need to change the 5th character of a 1-million-character
string, what is the most memory-efficient method?
38. Slicing Boundaries: What happens if the end index in string[start:end] exceeds the actual
length? Why doesn't it crash?
39. Method Chaining: Analyze the execution order of " hello ".strip().upper().replace("H", "J").
40. Encodings: What is the default encoding of Python 3 strings, and why does it matter for
"Internationalization"?

Section 5: Conditional Logic & Control Flow


41. Short-Circuit Evaluation: In if A or B:, if A is True, does Python ever look at B? Explain the
performance benefit.
42. Ternary Nesting: Write a one-line ternary operator that evaluates a score into "High",
"Medium", or "Low".
43. Truthy Complexity: Why is if [0]: True, but if 0: False?
44. Comparison Chaining: Explain how Python evaluates 1 < x < 10.
45. Indentation Significance: How does Python’s use of whitespace affect the "Parsing" of nested
conditional blocks?
46. Logical XOR: Python doesn't have a logical xor keyword. How do you simulate it using and, or,
and not?
47. Evaluation Order: Predict: if not True or True and False:.
48. Input Validation: Write a conditional block that ensures a user_input is both a digit AND within
the range 1-100 without crashing on string input.
49. The "Walrus" Operator: How does if (n := len(data)) > 10: improve conditional logic efficiency?
50. Match-Case (Python 3.10+): How does match-case differ from a standard if-elif-else chain in
terms of structural pattern matching?

Section 6: Error Handling & Debugging (The "Beginner Mistakes" Deep-Dive)


51. Syntax vs Logic Errors: Which is harder to find in an algorithm, and why?
52. Traceback Analysis: Explain how to read a Python "NameError" when a variable is used before
assignment.
53. Floating Point Rounding: How do you correctly compare two floats for equality in a conditional
statement?
54. The Assignment Trap: Why is if x = 10: a Syntax Error in Python, but valid in other languages?
55. Mutable Default Arguments: (Advanced) Why should you never use a List as a default
parameter in a function?
56. Indentation Consistency: Why does mixing Tabs and Spaces lead to an "IndentationError" even
if the code "looks" aligned?
57. Type Mismatch: Explain the error in len(12345).
58. Shadowing: What happens when you name a variable list or str?
59. Empty Collection Logic: Explain why if not my_list: is the "Pythonic" way to check if a list is
empty.
60. Input Sanitization: Why is eval(input()) considered one of the most dangerous commands in
Python?

[Note: Questions 61-100 continue in this pattern of combining multiple concepts (e.g., "Write a
program that uses a Tuple to store coordinates, then uses a conditional to check if the point is in a
specific String-named quadrant").]

Section 7: Integrative Performance & Design (61-100)


61. Optimization: You have 10,000 strings. You need to find duplicates. Use the "Relationship
between algorithms" to choose between a List-search or a Set-comparison.
62. Data Integrity: Design a "Property of a Good Algorithm" for a banking app that handles
concurrent variable updates.
63. String Buffering: Explain the internal logic of how StringIO handles massive string building
compared to standard concatenation.
64. Boolean Logic Mapping: Use a Dictionary to replace a complex 10-level if-elif chain.
65. Algorithm Scalability: Describe how an algorithm's performance changes when the data type
changes from List to Dictionary.
66. Memory Safety: Does Python's "NoneType" help or hinder algorithm design compared to C's
"Null"?
67. String Formatting Attacks: How can a poorly constructed .format() string lead to a security
vulnerability?
68. Deep Logic: Write a conditional that returns True only if exactly two out of three variables are
True.
69. Algorithm Portability: Why is "Pseudocode" essential when moving an algorithm from Python to
a low-level language?
70. Variable Lifetime: In a long-running Python script, how do you manually trigger the "Limitations
of Python" memory management to free up space?

I. Algorithms & Computational Logic (Questions 1-20)


1. Efficiency Paradox: Given two algorithms for the same task, why might a "Good Algorithm" with
more steps be preferred over a shorter one if the shorter one has high "Space Complexity"?
2. Pseudocode Logic: Write a pseudocode for a "Bubble Sort" logic. How does it satisfy the
"Finiteness" property?
3. Flowchart Architecture: Design a flowchart for a system that requires a "Nested Loop." How do
you represent the return to the inner loop vs. the outer loop?
4. Algorithm vs Program: Prove with an example why an algorithm is "Logical" while a program is
"Implementation."
5. Real-life Algorithm failure: Describe a real-life algorithm (like a recipe) that lacks "Definiteness."
What is the consequence?
6. Comparison: Contrast "Plain English" and "Pseudocode." In what technical scenario would Plain
English fail but Pseudocode succeed?
7. Algorithmic Relationship: Explain how the choice of a Data Structure (like a Set vs a List) can
fundamentally change the "Characteristics" of an algorithm.
8. Edge Case Logic: Develop an algorithm for a login system. List 3 "Bad Algorithm" properties it
would show if it didn't handle empty inputs.
9. Flowchart Symbols: Why is a "Decision Box" the only symbol in a flowchart that allows for two
exit paths?
10. Problem Solving: Translate a complex word problem (e.g., calculating compound interest) into a
10-step pseudocode.
11. Scalability: If an algorithm works for 10 items but crashes at 10,000, which "Characteristic of a
Good Algorithm" did it fail?
12. Logic Flow: Can a flowchart have multiple "Start" or "End" points? Justify your answer based on
"Finiteness."
13. Optimization: Take a 15-step algorithm and reduce it to 8 steps without losing "Input/Output"
accuracy.
14. Programming Algorithm: Explain the logic of a "Search" algorithm using only Python syntax
basics.
15. Bad Algorithm Analysis: Critically analyze an algorithm that contains a "Circular Dependency."
16. Ways to Represent: Why is a Flowchart better for visual learners but Pseudocode better for
developers?
17. Real-world Logic: How does a traffic light system demonstrate "Condition-based" algorithms?
18. Binary Logic: Represent a "Yes/No" decision tree using only if and else pseudocode.
19. Algorithm Importance: Why is the "Algorithm" phase the most expensive part of software
development?
20. Relationship: How does a "Variable" act as a container within a Flowchart's "Process" box?

II. Data Types & Memory Mechanics (Questions 21-40)


21. Memory Addressing: If x = 10, explain why changing x = 20 doesn't "change" the number 10 in
memory but reassigns the label.
22. Type Precision: Why does 0.1 + 0.2 == 0.3 return False in Python? Relate this to the Float data
type.
23. List vs Array: In your notes, you equated List to Array. Explain why a Python List is more complex
because it can hold "Heterogeneous" data.
24. NoneType Logic: In an algorithm, why would you initialize a variable to None instead of 0 or ""?
25. Structural Mapping: How does a Dictionary (Key-Value) optimize search time compared to a
List?
26. Immutability Conflict: Why can a Tuple be used as a Dictionary key, but a List cannot?
27. Boolean Arithmetic: What is the result of (True + True) * False? Explain why Python allows this
math.
28. None vs Null: Compare Python's NoneType to the concept of Null in Algorithms.
29. Set Theory: Explain the algorithmic advantage of a Set when you need to find "Unique" values in
a dataset of 1 million items.
30. Type Checking: Why is type(x) == int less "Pythonic" than isinstance(x, int)?
31. Float Conversion: What happens when you convert float(1e308)? Explain the concept of
"Infinity" in Python.
32. Integer Limits: Unlike C++, Python integers have "Arbitrary Precision." What does this mean for
large algorithms?
33. Character vs String: Python doesn't have a "Char" type. How does this affect the memory usage
of a single letter?
34. Boolean Truthiness: Why is an empty list [] considered False in a conditional statement?
35. Data Structure Importance: Choose the best data type from your notes for a "High-speed
lookup table" and justify it.
36. Complex Conversion: Explain the result of bool("False"). Why is it True?
37. Memory References: If L1 = [1, 2] and L2 = L1, why does [Link](3) change L1?
38. Type Error Analysis: Why does '3' + 3 fail, but '3' * 3 succeed?
39. NoneType Membership: Can None be a value inside a List? What are the implications for an
algorithm?
40. Mistake Analysis: Why is "forgetting to convert input to int" the most common beginner
mistake?

III. Variables & Scope (Questions 41-60)


41. Dynamic Typing: How does Python's "Variables" section differ from "Static Typing" where you
must declare int x?
42. Multiple Assignment: In the statement x, y = y, x, explain the "Under the hood" logic of how
Python swaps these without a third variable.
43. Pointer Aliasing: Explain the concept of "Reference Counting" using the a=10, b=a example from
your notes.
44. Global vs Local: What happens if a function tries to modify a global variable without the global
keyword?
45. Naming Collision: Why shouldn't you name a variable list or str?
46. Memory Efficiency: Which is more memory-efficient: x = x + 1 or x += 1?
47. Variable Scope Leakage: Does a variable defined inside an if block stay alive after the block
ends?
48. Constants: Since Python has no "real" constants, how do developers simulate "Immutability" for
variables?
49. Mutable Default Arguments: Why is it dangerous to use a List as a default value in a function?
50. Garbage Collection: When does a variable's memory actually get freed?
51. Reference Leak: Trace the memory in: a = [1], a = [2]. What happened to [1]?
52. Scope Resolution: Explain the LEGB rule (Local, Enclosing, Global, Built-in).
53. Deep vs Shallow Copy: How do you copy a list so that changes to the copy don't affect the
original?
54. Expression Evaluation: In x = 5 + 2 * 3, which variable "concept" is used to determine the order?
55. Variable Initialization: Why does Python throw a NameError if you try x += 1 before defining x?
56. Shadowing: Explain "Variable Shadowing" when a local variable has the same name as a global
one.
57. Reference equality: Explain the difference between == and is.
58. Large Data: How does [Link]() help in analyzing variable memory?
59. Naming Conventions: Why is camelCase discouraged in Python variables in favor of snake_case?
60. Input/Output Logic: Explain how print(f"{x=}") (Python 3.8+) assists in debugging variables.
IV. Strings & Manipulation (Questions 61-80)
61. Indexing Paradox: Why does s[-1] return the last character? Explain the "Negative Indexing"
algorithm.
62. Slicing Mechanics: Predict the output of "Python"[1:5:2] and explain the step parameter.
63. Immutability Proof: If I do s = "Hello"; s = "J" + s[1:], have I mutated the string or created a new
one?
64. Concatenation Performance: Why is "".join(list) faster than using + in a loop?
65. F-String Security: Compare f-strings to .format(). Which is more readable for complex
expressions?
66. Escape Character Logic: How do you print the literal string \n without creating a newline?
67. Membership Algorithms: How does the in operator work under the hood for a string?
68. String Methods: Difference between .find() and .index() when the character doesn't exist?
69. Encoding: How does Python's str type handle Unicode (emojis)?
70. Slicing Boundaries: Why doesn't "Hello"[1:100] throw an error?
71. Repetition Memory: What happens in memory when you run "A" * 1000000?
72. Split/Join Inverse: Prove that "".join([Link]()) doesn't always return the original string.
73. Triple Quotes: When should you use """ over \n?
74. Case Folding: Difference between .lower() and .casefold() for international strings?
75. Strip vs Replace: Which method is better for removing all spaces, not just leading/trailing?
76. Formatting Precision: How do you format a float inside an f-string to exactly 2 decimal places?
77. String Interning: Why does a = "hi"; b = "hi"; a is b sometimes return True?
78. Boolean Strings: Why does "0" evaluate to True but the integer 0 evaluate to False?
79. Comparison: How are strings compared? (Explain Lexicographical order/ASCII values).
80. Looping: How do you loop through a string to print only the vowels?

V. Conditionals & Control Flow (Questions 81-100)


81. Short-Circuiting: In if A or B:, if A is True, does B ever run? Why is this important for
performance?
82. Nested IF vs ELIF: When is a "Nested IF" required instead of a flat elif chain?
83. Ternary Complexity: Write a nested ternary operator for: If x > 10 "Big", else if x > 5 "Mid", else
"Small".
84. Logic Gates: How do you simulate an XOR gate using only if, and, and or?
85. Truthy/Falsy Deep-dive: Is if [0]: True or False? Explain based on collection rules.
86. Comparison Chaining: Explain how Python evaluates 1 < x < 10.
87. The Walrus Operator: How does if (n := len(x)) > 5: optimize a conditional?
88. Indentation Significance: How does Python's "Off-side rule" (indentation) prevent the "Dangling
Else" problem found in C++?
89. Logical Negation: Is if not x > 5: the same as if x <= 5:? Explain using De Morgan’s Laws.
90. Identity vs Equality: In a conditional, why should you use if x is None: instead of if x == None:?
91. Input Validation: Write a conditional block that checks if a string is a digit AND is an even
number without crashing.
92. Complexity: Why are deep "Nested IFs" considered a "Bad Algorithm" property?
93. Boolean Evaluation: Predict the output of if True or False and False:. (Explain operator
precedence).
94. User Input Logic: Why must we convert input() to a specific type before using comparison
operators like >?
95. The in Operator: How do you use if to check if a key exists in a dictionary vs. a value?
96. Empty State Logic: Why is if my_list: more "Pythonic" than if len(my_list) > 0:?
97. Switch-Case: Python didn't have switch until recently. How did developers use "Dictionaries" to
simulate it?
98. Operator Precedence: Does not have higher priority than and?
99. Structural Pattern Matching: (Advanced) Briefly explain how match-case (Python 3.10+) differs
from if-elif.
100. Final Integration: Design a conditional that checks if a variable is a String, has a length >
5, and starts with a capital letter.

Section 1: Algorithms & Flowchart Logic


1. An algorithm must terminate after a finite number of steps. If a programmer writes a logic that
processes infinitely, which "Characteristic of a Good Algorithm" is violated?
o A. Input
o B. Finiteness
o C. Definiteness
o D. Effectiveness
2. In a flowchart, a Diamond symbol is used for a decision. How many outgoing flow lines can a
decision box have in standard logic?
o A. Exactly one
o B. Exactly two (True/False)
o C. Any number
o D. Only three
3. Which representation of an algorithm is considered "Language Agnostic" and uses a mix of
natural language and code structures?
o A. Plain English
o B. Flowchart
o C. Pseudocode
o D. Python Program
4. What is the primary "Relationship between algorithm and programming"?
o A. They are the same thing.
o B. Programming is the design; the algorithm is the execution.
o C. The algorithm is the blueprint; programming is the implementation.
o D. Algorithms depend on specific programming languages.
5. A "Bad Algorithm" contains steps that are ambiguous. This is a failure of:
o A. Generality
o B. Definiteness
o C. Finiteness
o D. Input/Output

Section 2: Python Basics & Syntax


6. Python is often described as an "Interpreted" language. What does this mean for the "How
Python Works" concept?
o A. The code is converted to an EXE before running.
o B. The code is executed line-by-line by a Virtual Machine.
o C. Python doesn't require a compiler or interpreter.
o D. It runs directly on the hardware.
7. Which of the following is a "Python Keyword" that cannot be used as a variable name?
o A. string
o B. integer
o C. yield
o D. main
8. What is the purpose of the # symbol in Python syntax?
o A. To define a constant.
o B. To start a block of code.
o C. To create a single-line comment.
o D. To indicate a header.
9. When considering "Python Syntax Basics," which of these is mandatory for defining a code block
(like an IF statement)?
o A. Curly braces {}
o B. Semicolons ;
o C. Consistent Indentation
o D. Parentheses ()
10. The input() function always returns which data type by default?
o A. int
o B. float
o C. str
o D. bool

Section 3: Data Types & Memory Mechanics


11. If x = 5 and y = 5.0, which statement is true regarding their "Data Types"?
o A. They are both int.
o B. x is int and y is float.
o C. Python treats them as the same type.
o D. y is a Real type and x is a character.
12. Which data type is "Immutable," meaning its value cannot be changed after creation?
o A. List
o B. Dictionary
o C. Set
o D. Tuple
13. What is the result of type(3 / 3)?
o A. int
o B. float
o C. decimal
o D. str
14. In your notes, you listed "None type." What is its equivalent in many other algorithmic
languages?
o A. Zero
o B. False
o C. Null
o D. Void
15. Which of these is a "Mapping" data type?
o A. List
o B. Set
o C. Dictionary
o D. Tuple

Section 4: Variables & Scope


16. Given a = [1, 2] and b = a. If you run [Link](3), what is the value of a?
o A. [1, 2]
o B. [1, 2, 3]
o C. [3]
o D. Error
17. Which "Variable Naming Rule" is violated by my-variable = 10?
o A. Cannot start with a letter.
o B. Cannot contain hyphens.
o C. Must be all caps.
o D. Cannot use numbers.
18. What is "Variable Shadowing"?
o A. When a variable name is too long.
o B. When a local variable has the same name as a global variable.
o C. When two variables point to the same memory address.
o D. When a variable is deleted.
19. In "Multiple Assignments," what is the result of x, y = 10, 20; x, y = y, x?
o A. x=10, y=10
o B. x=20, y=10
o C. x=10, y=20
o D. x=20, y=20
20. What is the output of print(int("10") + float("5"))?
o A. 15
o B. 15.0
o C. "105"
o D. Error

Section 5: Strings & Slicing Deep-Dive


21. If s = "Examination", what does s[1:4] return?
o A. "Exa"
o B. "xam"
o C. "xami"
o D. "ami"
22. What is "String Immutability"?
o A. You cannot delete a string.
o B. You cannot change a specific character in a string using its index.
o C. You cannot add two strings together.
o D. You cannot use double quotes for strings.
23. Which "String Method" would you use to remove leading and trailing whitespace?
o A. .clean()
o B. .remove()
o C. .strip()
o D. .split()
24. What does the "f" in f-string stand for?
o A. Final
o B. Function
o C. Formatted
o D. Float
25. Predict the output: "Python" * 2
o A. "Python2"
o B. "PythonPython"
o C. Error
o D. "Python Python"

Section 6: Conditional Statements & Logic


26. In an if-elif-else chain, how many elif blocks can you have?
o A. Only one
o B. Only two
o C. As many as needed
o D. Zero
27. Which operator has the highest precedence in a conditional?
o A. and
o B. or
o C. not
o D. ==
28. What is "Short-circuit evaluation" in an OR statement?
o A. If the first part is True, the second part is not checked.
o B. If the first part is False, the second part is not checked.
o C. Both parts are checked simultaneously.
o D. It only works with integers.
29. Which of these is a "Truthy" value?
o A. 0
o B. ""
o C. [0]
o D. None
30. What is the output of 5 > 3 or 2 > 10 and 1 == 1?
o A. True
o B. False
o C. 1
o D. Error
Section 7: Variables & Memory References (Questions 31–45)
31. If x = 7 and you run x = x + 3, what is the algorithmic process occurring in memory?
o A. The value 7 is deleted and replaced by 10 in the same memory slot.
o B. A new integer object 10 is created, and x is updated to point to it.
o C. The variable x becomes a list containing 7 and 3.
o D. Python creates a constant named x.
32. What is the result of the multiple assignment a, b, c = [1, 2, 3]?
o A. a becomes [1, 2, 3]
o B. a=1, b=2, c=3
o C. ValueError
o D. a, b, c all point to the same list.
33. Which rule defines a "Local Variable"?
o A. It is defined at the very top of the script.
o B. It is defined inside a function and cannot be accessed outside.
o C. It starts with an underscore _.
o D. It never changes its value.
34. Why is 3_variable = "test" an invalid variable name?
o A. It uses an underscore.
o B. Variables cannot start with a digit.
o C. "test" is a keyword.
o D. It is too short.
35. When y = x is executed where x is a list, what is shared?
o A. The values are copied to a new memory location.
o B. Both variables share the same memory address (reference).
o C. Only the first element is shared.
o D. Nothing is shared; they are independent.

Section 8: String Architecture & Slicing (Questions 46–60)


36. What is the output of "Python"[-3:]?
o A. "hon"
o B. "Pyth"
o C. "yth"
o D. "n"
37. Which string method is used to turn "apple,banana,cherry" into a List?
o A. .join()
o B. .split()
o C. .strip()
o D. .index()
38. If s = "123", why does s[0] = "4" cause an error?
o A. String indices must be integers.
o B. Strings are immutable.
o C. The index 0 is reserved.
o D. You must use double quotes.
39. What does len("A\nB") return?
o A. 4
o B. 3
o C. 2
o D. 5
40. In f-string formatting, what happens if you write {2 + 2} inside the string?
o A. It prints the text "{2 + 2}".
o B. It evaluates to "4".
o C. It causes a Syntax Error.
o D. It prints "2 + 2 = 4".

Section 9: Advanced Conditionals & Truthiness (Questions 61–80)


41. What is the result of bool([])?
o A. True
o B. False
o C. None
o D. Error
42. How does the not operator behave?
o A. It multiplies the value by -1.
o B. It reverses the Boolean state.
o C. It checks if a variable is empty.
o D. It terminates the program.
43. Which of these is a "Short-circuit" result for if False and (unidentified_variable > 0):?
o A. It crashes because the variable isn't defined.
o B. It evaluates to False without checking the variable.
o C. It evaluates to True.
o D. It prompts for user input.
44. A "Nested IF" is best described as:
o A. An IF statement inside another IF statement.
o B. Two IF statements on the same line.
o C. An IF statement with multiple elif blocks.
o D. An IF statement that uses or.
45. The "Ternary Operator" x = 1 if True else 0 results in x being:
o A. True
o B. 1
o C. 0
o D. None

Section 10: Algorithmic Logic & Properties (Questions 81–100)


46. Which property ensures an algorithm is clear and unambiguous?
o A. Finiteness
o B. Definiteness
o C. Input
o D. Effectiveness
47. In your notes, "Pseudocode" is listed as a way to represent algorithms. What is its main
advantage?
o A. It can be run directly by a computer.
o B. It uses symbols like diamonds and squares.
o C. It allows developers to focus on logic without worrying about strict syntax.
o D. It is faster than Python.
48. A "Real-life algorithm" for a traffic light fails if it doesn't handle a power outage. This violates:
o A. Finiteness
o B. Generality/Robustness
o C. Output
o D. Initialization
49. What is the "Input" of an algorithm that calculates the area of a circle?
o A. The formula $\pi r^2$
o B. The Radius
o C. The Area
o D. The Print statement
50. Which data structure is best for an algorithm that requires "Last-In, First-Out" logic?
(Referencing List/Array)
o A. Dictionary
o B. Tuple
o C. List
o D. Set
Section 11: Memory, Variables & Assignments (Questions 61–75)
61. What is the outcome of x = 10; y = x; x = 20?
o A. y becomes 20
o B. y remains 10
o C. Both x and y are 20
o D. y becomes None
62. In Python, "Variable Scope" refers to:
o A. The amount of memory a variable uses.
o B. The part of the program where a variable is accessible.
o C. The speed at which a variable is processed.
o D. The data type of the variable.
63. What happens when you run a, b = 1, 2, 3?
o A. a=1, b=2 and 3 is ignored.
o B. a=1, b=2 and c=3 is automatically created.
o C. It raises a ValueError (too many values to unpack).
o D. It creates a tuple.
64. Which statement about "Constants" in Python is true?
o A. Python has a const keyword.
o B. Constants are enforced by the interpreter.
o C. They are indicated by uppercase names (e.g., PI = 3.14) by convention only.
o D. Constants cannot be redefined once set.
65. The type() function is used to:
o A. Convert a variable to a different type.
o B. Determine the class/type of an object.
o C. Change a variable's name.
o D. Input data from the user.

Section 12: Strings & Data Structures (Questions 76–90)


66. Which operation will result in an error on a String?
o A. s[0] = 'A'
o B. s + " more"
o C. s * 3
o D. len(s)
67. If list_a = [1, 2, 3], what is the result of list_a[1:1]?
o A. [1]
o B. [2]
o C. [] (Empty list)
o D. Error
68. What is the result of "apple" in "pineapple"?
o A. True
o B. False
o C. 1
o D. Error
69. Which data type is best for storing a "Key-Value" pair?
o A. List
o B. Set
o C. Dictionary
o D. Tuple
70. The .join() method is called on:
o A. A list of strings.
o B. The separator string.
o C. An integer.
o D. The terminal.
71. What is the result of list("Hi")?
o A. ["Hi"]
o B. ["H", "i"]
o C. ("H", "i")
o D. Error
72. What does [Link]() do to the original string s?
o A. Changes the original string to uppercase.
o B. Returns a new uppercase string; s remains unchanged.
o C. Deletes the original string.
o D. Capitalizes only the first letter.

Section 13: Conditional Logic & Algorithms (Questions 91–100)


73. What is the result of not (5 > 10)?
o A. True
o B. False
o C. 5
o D. -5
74. In an if-elif-else structure, what happens if the if condition is True?
o A. All elif and else blocks are also checked.
o B. Only the if block runs; the others are skipped.
o C. The code crashes.
o D. Only the else block runs.
75. Which is a "Comparison Operator"?
o A. =
o B. ==
o C. +
o D. and
76. In your notes, "None type" is described as Null. What is if None: evaluated as?
o A. True
o B. False
o C. Error
o D. 0
77. What is the result of 10 > 5 and 5 > 10?
o A. True
o B. False
o C. 10
o D. 5
78. Which flowchart symbol represents the input of data?
o A. Rectangle
o B. Parallelogram
o C. Diamond
o D. Oval
79. What is "Algorithm Efficiency"?
o A. How long the algorithm takes to write.
o B. How many resources (time/memory) an algorithm uses.
o C. The color of the flowchart.
o D. Using the most complex variables possible.
80. If x = "5", what is the result of x * 3?
o A. 15
o B. "555"
o C. "15"
o D. Error
Section 6: Logical Operators & Truthiness (81–90)
81. What is the outcome of the expression not (10 > 5 or 2 > 10)?
o A. True
o B. False
o C. None
o D. 0
82. In Python’s short-circuit logic, which statement is true for the or operator?
o A. If the first operand is True, the second operand is never evaluated.
o B. If the first operand is False, the second operand is never evaluated.
o C. Both operands are always evaluated to ensure accuracy.
o D. It only works if both operands are of the same data type.
83. Which of the following would be evaluated as a "Falsy" value in a conditional?
o A. [None]
o B. 0.0
o C. "False"
o D. True
84. What is the result of bool(" ") (a string containing one space)?
o A. False
o B. True
o C. None
o D. Error
85. What is the precedence order (from highest to lowest) for logical operators in Python?
o A. or, and, not
o B. and, or, not
o C. not, and, or
o D. not, or, and
86. In the expression if x in "Python":, if x = "py", the result is False. Why?
o A. The in operator only works for single characters.
o B. Strings are case-sensitive.
o C. "py" is a keyword.
o D. Strings are immutable.
87. Which comparison operator checks if two variables point to the same object in memory
(Identity)?
o A. ==
o B. is
o C. in
o D. id
88. What is the result of 10 > 5 > 2?
o A. True
o B. False
o C. Error
o D. 10
89. What happens when you use the not operator on a non-boolean value like not 5?
o A. It returns -5.
o B. It returns False.
o C. It returns True.
o D. It raises a TypeError.
90. Which logic is used to check if a value is within a specific range (e.g., between 1 and 10)?
o A. if 1 < x > 10:
o B. if 1 < x < 10:
o C. if x == 1 to 10:
o D. if x in range(1, 10): (using the range algorithm)

Section 7: Integrative Algorithmic Logic (91–100)


91. If an algorithm requires "Last-In, First-Out" behavior, which Python data type from your notes
is most efficient to use?
o A. Tuple
o B. Set
o C. List
o D. Dictionary
92. Which of these represents a "Semantic/Logic Error" rather than a Syntax Error?
o A. if x = 10:
o B. print("Hello"
o C. average = (a + b) / 0 (Mathematical impossibility)
o D. average = a + b / 2 (Missing parentheses for the intended logic)
93. In a flowchart, what is the significance of an arrow pointing back to a previous step?
o A. It indicates the end of the program.
o B. It represents a "Loop" or repetition in the algorithm.
o C. It means the input was invalid.
o D. It signifies a constant variable.
94. Why is the "NoneType" useful in variable assignment?
o A. It clears the computer's entire memory.
o B. It represents a variable that exists but has no value assigned yet.
o C. It converts a string into an integer.
o D. It is the fastest data type in Python.
95. Which "Property of a Bad Algorithm" is most likely to cause a computer to crash or freeze?
o A. Lack of Input
o B. Lack of Finiteness (Infinite Loop)
o C. Using too many comments
o D. Using lowercase variable names
96. What is the result of float(int("10"))?
o A. 10
o B. 10.0
o C. "10.0"
o D. Error
97. When using multiple assignments like x, y = 1, 2, how does Python prevent data loss during a
swap like x, y = y, x?
o A. It creates temporary internal storage for the values before assigning them.
o B. It uses a special "swap" keyword.
o C. It deletes the variables and recreates them.
o D. It moves the memory addresses to a different hardware sector.
98. Which character is required at the end of an if, elif, or else statement to avoid a Syntax Error?
o A. ;
o B. .
o C. :
o D. !
99. What is the "Membership Operator" used to check if a key exists in a Dictionary?
o A. exists
o B. in
o C. ==
o D. ?
100. If an algorithm is "Effective," what does that imply? * A. It is written in the newest
version of Python. * B. Each step is basic enough to be performed exactly by the processor. * C.
It has a beautiful flowchart. * D. It uses only global variables.

Set4:

Practicals:

Phase 1: Algorithmic Logic & Flow (Questions 1-10)


1. Logic Synthesis: Write the Pseudocode for an algorithm that finds the largest of four numbers
using the minimum number of comparison operators possible.
2. Flowchart Analysis: Draw or describe a flowchart for a "Login System" that gives the user
exactly 3 attempts to enter the correct password before locking them out.
3. Efficiency Check: You have a list of 1,000 names. Algorithm A searches from the start to the end.
Algorithm B searches from both ends simultaneously. Which "Characteristic of a Good
Algorithm" makes Algorithm B potentially better?
4. Error Handling Algorithm: Design an algorithm in Plain English to calculate the square root of a
number, including a check for negative inputs.
5. Dry Run: Given an algorithm: 1. Start 2. x=1 3. y=10 4. While x < y: x = x * 2 5. Output x. What is
the final output?
6. Loop Logic: How would you represent a "Repeat-Until" loop in a flowchart using only the
standard Diamond (Decision) and Rectangle (Process) boxes?
7. Data Relationship: Explain why using a List instead of a Dictionary would make a "Searching
Algorithm" for 1 million records slower.
8. Algorithm Transformation: Convert the following Plain English into Pseudocode: "Check if a
student's score is above 50. If it is, check if it's above 90 for a distinction. Otherwise, they fail."
9. Finiteness Challenge: Create an example of an algorithm that satisfies "Definiteness" but fails
"Finiteness."
10. Real-Life Mapping: Map the steps of "Withdrawing Money from an ATM" to a formal
programming algorithm structure (Input, Process, Output).

Phase 2: Variables & Memory Architecture (Questions 11-20)


11. Memory Referencing: Predict the output and explain why:
Python
a = [1, 2, 3]
b=a
b[0] = 99
print(a)
12. Immutability Testing: Why does the following code crash?
Python
name = "Python"
name[0] = "p"
13. Dynamic Re-assignment: If x = 10 and then x = "Ten", what happens to the original integer
object 10 in Python’s memory?
14. Variable Scope Conflict: If a variable count is defined as 10 globally and 5 locally inside a
function, what value is used when count += 1 is called inside that function?
15. Type Casting Complexity: Write a code snippet that takes a float as input, converts it to an
integer, and then turns that integer into a string formatted as "The result is: [number]".
16. Multiple Assignment Logic: Using a single line of code, swap the values of three variables: a=1,
b=2, c=3 so that a=2, b=3, c=1.
17. Constants Simulation: Since Python doesn't have a const keyword, write a snippet showing the
naming convention for a "Gravity" constant and explain why we use it.
18. Memory Leak Simulation: If you continuously append items to a list in a loop, which "Limitation
of Python" mentioned in your notes are you likely to hit?
19. Augmented Assignment: What is the specific difference between x = x + 1 and x += 1 in terms of
how Python processes the variable?
20. Naming Rules: Identify the single invalid variable in this list and explain why: _data, data_2,
2_data, Data.

Phase 3: Data Types & Structural Mechanics (Questions 21-30)


21. Collection Comparison: You need to store a list of student IDs that must not change and must
be ordered. Which data type from your notes should you use?
22. Heterogeneous Lists: Create a list containing an integer, a float, a string, and another list. Access
the second element of the internal list.
23. Boolean Evaluation: Evaluate the truthiness of this expression: bool(0) or bool("0"). Explain the
result.
24. Dictionary Keys: Why can a Tuple be used as a key in a dictionary, but a List cannot?
25. NoneType Usage: Write a conditional statement that checks if a variable database_connection
is None before attempting to close it.
26. Float Precision: Explain why 0.1 + 0.2 == 0.3 might return False in Python based on how "Float"
works.
27. Set Logic: You have two lists of email addresses. Write the logic to find only the email addresses
that appear in both lists without using a loop.
28. Mapping Application: Create a dictionary where keys are "Product Names" and values are
"Prices." Write code to increase all prices by 10%.
29. Type Checking: Write a function that accepts an input and prints "Numeric" if it's an int or float,
and "Text" if it's a string.
30. Empty State Logic: Why is if my_list: more efficient than if len(my_list) > 0:?

Phase 4: String Manipulation & Slicing (Questions 31-40)


31. Negative Slicing: Given s = "University", extract the word "vers" using only negative indices.
32. String Formatting: Using f-strings, take a variable price = 19.99 and tax = 0.15 and print: "The
total is $22.99" (calculated inside the string).
33. Method Chaining: Take the string " learning python is fun ", remove the spaces, capitalize the
first letter of every word, and replace "fun" with "awesome."
34. Palindrome Algorithm: Write a 1-line expression using Slicing to check if a string is a palindrome
(reads the same backward).
35. Escape Characters: Write a single string that prints: Path: C:\Users\Desktop Action: "Run"
36. String Length Logic: Why does len("\n\t") return 2 instead of 4?
37. Index Error Prevention: Write a code snippet that safely prints the 10th character of a string
only if the string is long enough.
38. Concatenation vs. Join: Explain why using ''.join(['a', 'b', 'c']) is better for performance than 'a' +
'b' + 'c'.
39. Substring Search: Write a conditional that checks if the domain "@[Link]" exists in a string
variable email.
40. Immutability Workaround: If you want to change the third letter of "House" to "r" to make
"Horse," write the code to do it since strings are immutable.
Phase 5: Conditional Statements & Deep Logic (Questions 41-50)
41. Logical Priority: Predict the result of: if True or False and False:. Explain the order of and vs or.
42. Short-Circuiting: In the expression if x > 0 or y / 0 == 0:, if x = 5, will the program crash? Why or
why not?
43. Nested IF Optimization: Rewrite a 3-level Nested IF statement into a single IF statement using
logical operators.
44. Ternary Practice: Write a one-line Ternary operator that assigns "Child" if age < 13, "Teen" if age
< 20, and "Adult" otherwise.
45. Input Sanitization: Write a conditional that checks if a user's input is a number. If it is, check if
it's even. If it's not a number, print an error.
46. Membership Check: Given list_a = [1, 2, [3, 4]], write a conditional to check if 3 is in list_a.
(Careful with nested structures!)
47. Truthy/Falsy Deep Dive: Which of these will execute? if "": print("A") if [0]: print("B") if None:
print("C")
48. Comparison Chaining: Explain exactly how Python evaluates 5 > 3 > 1.
49. Logic Gate Simulation: Write a conditional that returns True only if exactly one of two boolean
variables (a, b) is True.
50. Debugging Challenge: Identify three syntax/logic errors in this snippet:
Python
age = input("Age: ")
if age > 18
print(Success)
else:
print("Fail")

You might also like