Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer in python please Write a program that is able to act like your personal p

ID: 3755586 • Letter: A

Question

answer in python please Write a program that is able to act like your personal pedometer, by asking the user how many steps they travelled in one week. The information calculated must be the minimum and maximum steps travelled (and the days that you walked those steps!). Make sure you use a loop to solve this problem. You need to create a program that does the following, in this exact order: 1. Get the number of steps travelled each day 2. Calculate and display the minimum & maximum steps walked. 3. Calculate and display the day those steps were taken. As the program asks the user for the steps walked each day, it must print out the number of the day, so they don’t lose track of which one they are on (see the sample output). You do not have to validate user input for this problem. You can assume that all numbers entered with be bigger than or equal to 0.

Explanation / Answer

Program using while loop

largest = None
smallest = None
num = None
i=1
while i<8:
    num = int(input("Enter the number of steps travelled day "+str(i)+" : "))
  
    if largest is None:
        largest = num
        smallest = num

    if num>largest:
        largest=num
        maxday=i
    if num<smallest:
        smallest=num
        minday=i
    i=i+1

print ("Maximum is ", largest," on day ",maxday)
print ("Minimum is ", smallest," on day ",minday)

Output

Enter the number of steps travelled day 1 : 45
Enter the number of steps travelled day 2 : 90
Enter the number of steps travelled day 3 : 12
Enter the number of steps travelled day 4 : 56
Enter the number of steps travelled day 5 : 32
Enter the number of steps travelled day 6 : 75
Enter the number of steps travelled day 7 : 11
Maximum is 90 on day 2
Minimum is 11 on day 7

Program

def main():
    print("Enter the number of steps travelled each day : ")
    steps = []
    for i in range(7):
        steps.append(int(input("Day "+str(i)+" : ")))
    max=steps[1]
    min=steps[1]
    for i in range(7):
        if (steps[i]>max):
            max=steps[i]
            maxday=i
   
    for i in range(7):
        if (steps[i]<min):
            min=steps[i]
            minday=i
           
    print(" Maximum steps walked is "+str(max)+" on day "+str(maxday))
    print(" Minimum steps walked is "+str(min)+" on day "+str(minday))
main()