-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_parctice2.py
More file actions
42 lines (33 loc) · 1004 Bytes
/
list_parctice2.py
File metadata and controls
42 lines (33 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''1. Write a Python program to find the maximum element in a list of numbers without
max functions
numbers = [10, 20, 4, 45, 99]
The maximum element is: 99'''
# n= [99,10, 20, 4, 45]
# s=n[0]
# for i in range(len(n)):
# if(n[i]>s):
# s=n[i]
# print(s)
# for i in n:
# if i>s:
# s=i
# print(s)
'''2. Write a Python program to sum all the elements in a list of numbers.
a. numbers = [10, 20, 30, 40]
b. The sum of all elements is: 100'''
# numbers = [10, 20, 30, 40]
# sum=0
# for i in numbers:
# sum=sum+i
# print(sum)
'''3. Write a Python program to reverse a list without reverse or slicing operator
a. numbers = [1, 2, 3, 4, 5]
b. Reversed list: [5, 4, 3, 2, 1]'''
# numbers = [1, 2, 3, 4, 5]
# r=[]
# for i in range(len(numbers)-1,-1,-1):
# r.append(numbers[i])
# print(r)
'''4. Write a Python program to sort a list in ascending order without sort functions'''
n= [99,10, 20, 4, 45]
for i in range(len(n)):