0% found this document useful (0 votes)
5 views12 pages

26 May 2025 Python Foundations Question Bank

The document is a comprehensive Python Foundations Question Bank covering various topics such as Python basics, conditional statements, loops, lists, tuples, dictionaries, strings, and functions. It includes multiple-choice questions, definitions of concepts, coding questions, and true or false questions to assess understanding of Python programming. The structure is divided into sections, each focusing on different aspects of Python programming knowledge and skills.

Uploaded by

Simamkele
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)
5 views12 pages

26 May 2025 Python Foundations Question Bank

The document is a comprehensive Python Foundations Question Bank covering various topics such as Python basics, conditional statements, loops, lists, tuples, dictionaries, strings, and functions. It includes multiple-choice questions, definitions of concepts, coding questions, and true or false questions to assess understanding of Python programming. The structure is divided into sections, each focusing on different aspects of Python programming knowledge and skills.

Uploaded by

Simamkele
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 Foundations Question Bank

Topics Covered: 1. Python Basics 2. Conditional Statements 3. Loops 4. Lists 5. Tuples 6. Dictionaries 7.
Strings 8. Functions

SECTION A — 50 Multiple Choice Questions


Python Basics
1. Which function is used to display output in Python? A. input() B. print() C. display() D. output()

2. Which data type stores whole numbers? A. float B. str C. int D. bool

3. Which symbol is used for comments in Python? A. // B. <!-- --> C. # D. **

4. What is the output type of:

x = 5 / 2

A. int B. str C. float D. bool

1. Which function receives user input? A. print() B. input() C. get() D. scan()

2. Which operator represents exponentiation? A. ^ B. ** C. // D. %

Conditional Statements
1. Which keyword starts a condition in Python? A. condition B. loop C. if D. check

2. Which keyword is used for another condition after if? A. otherwise B. elseif C. elif D. nextif

3. Which keyword executes when all conditions are false? A. else B. stop C. endif D. none

4. What is the output?

x = 5
if x > 3:
print("Yes")

A. No B. Yes C. Error D. Nothing

1. Which operator means “equal to”? A. = B. == C. === D. !=

1
2. Which logical operator requires both conditions to be true? A. or B. and C. not D. xor

Loops
1. Which loop repeats while a condition is true? A. for B. while C. repeat D. loop

2. Which function commonly works with for loops? A. list() B. range() C. int() D. float()

3. What is the output?

for i in range(3):
print(i)

A. 1 2 3 B. 0 1 2 C. 0 1 2 3 D. 1 2

1. Which statement skips the current iteration? A. stop B. break C. continue D. pass

2. Which statement completely exits a loop? A. continue B. stop C. break D. skip

3. Infinite loops are mostly caused by: A. missing variables B. missing print() C. conditions never
becoming false D. syntax errors

Lists
1. Which brackets define a list? A. () B. {} C. [] D. <>

2. Which method adds an item to a list? A. insert() B. add() C. append() D. push()

3. Which method removes the last item? A. remove() B. delete() C. pop() D. clear()

4. What is the index of the first element? A. 1 B. -1 C. 0 D. 2

5. What is the output?

numbers = [1,2,3]
print(numbers[1])

A. 1 B. 2 C. 3 D. Error

1. Which method sorts a list? A. arrange() B. order() C. sort() D. organize()

Tuples
1. Which brackets define a tuple? A. [] B. {} C. () D. <>

2. Tuples are: A. mutable B. changeable C. immutable D. deletable

2
3. What is the output?

t = (1,2,3)
print(t[0])

A. 1 B. 2 C. 3 D. Error

1. Which method converts a tuple to a list? A. tuple() B. convert() C. list() D. dict()

2. Which statement about tuples is true? A. They can grow automatically B. They are mutable C.
They are ordered D. They use curly braces

3. Which symbol separates tuple values? A. ; B. : C. , D. #

Dictionaries
1. Dictionaries store data as: A. indexes only B. key-value pairs C. rows only D. numbers only

2. Which brackets define dictionaries? A. [] B. () C. {} D. <>

3. What is the output?

student = {"name":"Sam"}
print(student["name"])

A. name B. Sam C. Error D. student

1. Which method returns all keys? A. keys() B. values() C. items() D. getkeys()

2. Which method returns all values? A. keys() B. values() C. items() D. getvalues()

3. Which method safely retrieves a value? A. fetch() B. retrieve() C. get() D. value()

Strings
1. Strings are enclosed in: A. quotes B. brackets C. braces D. commas

2. Which method converts text to uppercase? A. upper() B. capitalize() C. big() D. up()

3. Which method removes spaces at both ends? A. trim() B. strip() C. remove() D. clean()

4. What is the output?

text = "Python"
print(len(text))

3
A. 5 B. 6 C. 7 D. Error

1. Which operator joins strings? A. * B. + C. % D. /

2. Which method replaces text? A. replace() B. switch() C. convert() D. update()

Functions
1. Which keyword defines a function? A. function B. define C. fun D. def

2. What is the output?

def greet():
print("Hello")

greet()

A. greet B. Hello C. Error D. Nothing

1. A function parameter is: A. returned value B. input to a function C. output D. variable outside
function

2. Which keyword returns a value from a function? A. send B. output C. return D. print

3. Functions help improve: A. repetition B. modularity C. syntax errors D. hardware

4. Which statement calls a function? A. call greet B. greet[] C. greet() D. function greet

5. What is the scope of a local variable? A. entire program B. internet C. only inside function D. all
files

6. Which of the following is true about functions? A. They cannot return values B. They reduce code
reuse C. They improve organization D. They are only for math

SECTION B — 30 Definitions of Concepts


1. Define variable.
2. Define data type.
3. Define integer.
4. Define float.
5. Define string.
6. Define boolean.
7. Define operator.
8. Define conditional statement.
9. Define if statement.
10. Define logical operator.

4
11. Define loop.
12. Define for loop.
13. Define while loop.
14. Define iteration.
15. Define infinite loop.
16. Define list.
17. Define tuple.
18. Define dictionary.
19. Define key-value pair.
20. Define indexing.
21. Define slicing.
22. Define string.
23. Define function.
24. Define parameter.
25. Define argument.
26. Define return value.
27. Define local variable.
28. Define modular programming.
29. Define mutable object.
30. Define immutable object.

SECTION C — 30 “What Is Displayed?” Questions


1.

print(5 + 3)

2.

x = 10
print(x)

3.

print("Python")

4.

print(10 // 3)

5.

5
print(2 ** 3)

6.

x = 5
if x > 2:
print("Yes")

7.

x = 1
if x > 5:
print("A")
else:
print("B")

8.

for i in range(3):
print(i)

9.

count = 0
while count < 3:
print(count)
count += 1

10.

numbers = [1,2,3]
print(numbers[2])

11.

numbers = [1,2]
[Link](3)
print(numbers)

12.

6
print(len([1,2,3,4]))

13.

t = (10,20)
print(t[1])

14.

student = {"name":"John"}
print(student["name"])

15.

print("Hello".upper())

16.

print("PYTHON".lower())

17.

print(len("Computer"))

18.

print("Py" + "thon")

19.

def add(a,b):
return a+b

print(add(2,3))

20.

def greet():
print("Hi")

7
greet()

21.

for i in range(1,4):
print(i * 2)

22.

x = [1,2,3]
[Link]()
print(x)

23.

print(10 % 3)

24.

print(5 == 5)

25.

print(5 != 3)

26.

x = "Python"
print(x[0])

27.

print("abc" * 2)

28.

numbers = [5,1,3]
[Link]()
print(numbers)

8
29.

d = {"a":1,"b":2}
print([Link]())

30.

def square(x):
return x*x

print(square(4))

SECTION D — 100 Coding Questions


1. Write a program to input two numbers and display their sum.
2. Write a program to calculate the area of a rectangle.
3. Write a program to calculate the perimeter of a square.
4. Write a program to convert Celsius to Fahrenheit.
5. Write a program to find the largest of two numbers.
6. Write a program to determine if a number is positive or negative.
7. Write a program to determine if a number is even or odd.
8. Write a program to check if a number is divisible by 5.
9. Write a program to display numbers from 1 to 10.
10. Write a program to display even numbers from 1 to 20.
11. Write a program to display odd numbers from 1 to 20.
12. Write a program to calculate the sum of numbers from 1 to N.
13. Write a program to calculate factorial using a loop.
14. Write a program to display a multiplication table.
15. Write a program to reverse a number.
16. Write a program to count digits in a number.
17. Write a program to find the largest digit in a number.
18. Write a program to check if a number is a palindrome.
19. Write a program to display Fibonacci sequence.
20. Write a program to determine if a number is prime.
21. Write a program to print all prime numbers between 1 and 100.
22. Write a program to calculate GCD.
23. Write a program to calculate LCM.
24. Write a program to create a list of 5 numbers.
25. Write a program to find the maximum value in a list.
26. Write a program to find the minimum value in a list.
27. Write a program to calculate list average.
28. Write a program to remove duplicates from a list.
29. Write a program to sort a list.
30. Write a program to reverse a list.
31. Write a program to count even numbers in a list.
32. Write a program to count odd numbers in a list.

9
33. Write a program to merge two lists.
34. Write a program to rotate a list left.
35. Write a program to rotate a list right.
36. Write a program to find second largest number in a list.
37. Write a program to check if an element exists in a list.
38. Write a program to create a tuple.
39. Write a program to access tuple elements.
40. Write a program to convert tuple to list.
41. Write a program to count tuple elements.
42. Write a program to create a dictionary.
43. Write a program to display dictionary keys.
44. Write a program to display dictionary values.
45. Write a program to update dictionary values.
46. Write a program to merge dictionaries.
47. Write a program to count characters using a dictionary.
48. Write a program to count word frequency.
49. Write a program to invert a dictionary.
50. Write a program to find the key with maximum value.
51. Write a program to count vowels in a string.
52. Write a program to count consonants.
53. Write a program to reverse a string.
54. Write a program to check string palindrome.
55. Write a program to convert string to uppercase.
56. Write a program to convert string to lowercase.
57. Write a program to remove spaces from a string.
58. Write a program to replace vowels with *.
59. Write a program to count uppercase letters.
60. Write a program to count lowercase letters.
61. Write a program to check if two strings are anagrams.
62. Write a program to find the longest word.
63. Write a function to add two numbers.
64. Write a function to subtract two numbers.
65. Write a function to multiply two numbers.
66. Write a function to divide two numbers.
67. Write a function to calculate factorial.
68. Write a recursive factorial function.
69. Write a function to check prime numbers.
70. Write a function to find maximum in a list.
71. Write a function to count vowels.
72. Write a function to reverse a string.
73. Write a function to calculate square.
74. Write a function to calculate cube.
75. Write a function to display multiplication table.
76. Write a program using nested loops to print a square star pattern.
77. Write a program to print a pyramid pattern.
78. Write a program to print Floyd’s triangle.
79. Write a program to print Pascal’s triangle.
80. Write a program to generate random numbers.
81. Write a number guessing game.
82. Write a calculator program.
83. Write a menu-driven program.

10
84. Write a program to validate integer input.
85. Write a program to repeatedly ask for input until valid.
86. Write a program to prevent division by zero.
87. Write a program to create a list of squares.
88. Write a program to create a list of cubes.
89. Write a program using list comprehension.
90. Write a program to flatten nested lists.
91. Write a program to sum elements at even indices.
92. Write a program to sum elements at odd indices.
93. Write a program to count positive and negative numbers.
94. Write a program to split a list into halves.
95. Write a program to check whether a list is empty.
96. Write a program to concatenate strings.
97. Write a program to calculate average marks.
98. Write a program to store student data in a dictionary.
99. Write a function that returns the smallest number in a list.
100. Write a function that returns the second smallest number in a list.

SECTION E — 50 True or False Questions


1. Python is case-sensitive.
2. Variables must be declared before use.
3. Lists are mutable.
4. Tuples are immutable.
5. Dictionaries use key-value pairs.
6. Strings are mutable.
7. The print() function displays output.
8. input() returns user input as a string.
9. Python uses indentation to define blocks.
10. A while loop can become infinite.
11. The == operator checks equality.
12. The = operator assigns values.
13. range(5) starts at 1.
14. Lists use square brackets.
15. Tuples use parentheses.
16. Dictionaries use curly braces.
17. len() returns the number of elements.
18. append() adds items to a list.
19. pop() removes the last item.
20. sort() arranges list elements.
21. Strings can be indexed.
22. Python indexing starts at 0.
23. Functions improve code reuse.
24. def defines a function.
25. return sends back a value.
26. A parameter is the same as an argument.
27. Local variables exist only inside functions.
28. Infinite loops are always useful.
29. break exits a loop.

11
30. continue skips an iteration.
31. Dictionaries cannot have duplicate keys.
32. Lists can store mixed data types.
33. Tuples can contain lists.
34. Strings can be concatenated.
35. upper() converts text to uppercase.
36. lower() converts text to lowercase.
37. strip() removes spaces at both ends.
38. Python supports recursion.
39. Functions can call other functions.
40. A function can return multiple values.
41. range() produces sequences.
42. Lists are ordered collections.
43. Dictionaries are unordered in older Python versions.
44. Python supports nested loops.
45. A loop can exist inside another loop.
46. if statements execute conditions.
47. elif means “else if”.
48. Comments are ignored by Python.
49. Strings are enclosed in quotes.
50. Python is an interpreted language.

12

You might also like