Professional Documents
Culture Documents
Hyrje Ne Programim Me Python - Provim - Eng
Hyrje Ne Programim Me Python - Provim - Eng
1. Which of the following methods is correct for finding the first position of a character or a
substring within a string in Python?
A) find()
B) index()
C) search()
D) locate()
A) [1, 2, 3, 4, 5]
B) (1, 2, 3, 4, 5)
C) {1, 2, 3, 4, 5}
D) 1, 2, 3, 4, 5
numbers = [1, 2, 3, 4, 5]
s = [x**2 for x in numbers if x % 2 == 0]
print(s)
a = [1, 3, 5]
b = [2, 4, 6]
c=a+b
print(c)
c.sort()
print(c)
i=5
while True:
if i == 8:
Break
print(i)
i += 1
Coding Questions (2 * 25p)
9. Implement a linear search algorithm using the While command in Python (25p)
10. Calculate the common elements for two given lists as parameters in a function where the
result should not be sorted. (25p)
Output: O = [5, 3, 4, 9]