Skip to content

Commit 5ce0dff

Browse files
authored
practice2.py , practice3.py (#11)
* Add files via upload * Delete 2.py * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update practice2.py * Update practice3.py
1 parent eb4327d commit 5ce0dff

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

Images/2.png

8.53 KB
Loading

Images/3.png

8.93 KB
Loading

practice2.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#EXERCISE 2 - Summing numbers
2+
3+
def mysum(num):
4+
t = 0
5+
for num in num:
6+
t += num
7+
return t
8+
9+
10+
n = int(input('how many number you want to add'))
11+
list1 = []
12+
for i in range(0,n):
13+
a = int(input())
14+
list1.insert(i,a)
15+
16+
print(mysum(list1))

practice3.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#EXERCISE 3 - Run timing
2+
3+
def run_timing():
4+
totalRuns = 0
5+
totalTime = 0
6+
while True:
7+
timing = input('Enter 10 km run time: ').strip()
8+
9+
if not timing:
10+
break
11+
12+
totalTime += float(timing)
13+
totalRuns += 1
14+
averageTime = totalTime / totalRuns
15+
print(f'Average of {averageTime}, over {totalRuns} runs')
16+
17+
run_timing()

0 commit comments

Comments
 (0)