Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task#1: Write a Python program that keeps asking user for the calories burnt on a given day. At the end, the program should print the

Task#1:

Write a Python program that keeps asking user for the calories burnt on a given day. At the end, the program should print the total calories burnt, along with the average calories burnt per day by the user.

Additionally, the user should enter 0 to quit the program. Also, if the user enters negative calories, then the program should print a message saying, "Please enter valid Calories!". The negative values should be ignored, and not added to the total.

Here is an example of how the output should be:

Enter calories burnt on day 1: 100

Enter calories burnt on day 2: 200

Enter calories burnt on day 3: 300

Enter calories burnt on day 4: -150  #negative value 

Please enter valid Calories!

Enter calories burnt on day 4: 400

Enter calories burnt on day 5: 500

Enter calories burnt on day 6: -300  #negative value 

Please enter valid Calories!

Enter calories burnt on day 6: 600

Enter calories burnt on day 7: 700

Enter calories burnt on day 8: 0#quit

Total calories burnt so far: 2800

Average calories burnt so far: 400.0

Task#2:

Consider the following dictionary object:

studentInfo = {

'name':'Sam',

'scores': [ ...m@gmail.com',

'address':'123 Main St, MI',

'hobbies': ['reading','sports','traveling']

}

1.Write a loop to iterate through all the keys of thestudentInfodictionary object.

2.Write a loop to iterate through all the values of thestudentInfodictionary object.

3.Write a loop to iterate through all the items (pairs) of thestudentInfodictionary object.

4.Using the dictionary object above, print the total score scored by 'Sam'.

5.Using the dictionary object above, print the second hobby from the 'hobbies' list.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions