Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Exam #1 Write a program for a library: – We check in a customer named John Smith

Exam #1 Write a program for a library: – We check in a customer named John Smith

Computer Science

Exam #1

  1. Write a program for a library:
    – We check in a customer named John Smith. He’s 18 years old and is a new member of the library:
    A. Define three variables here
    –    a. name
    –    b. age
    –    c. “New” or “Existing” member

B. Print out all the variables

 

  1. course = ‘Intro to Python’
    – print(course[0:3])
    – print(course[0:])
    – print(course[:5])

– print(course[-1])
– another=course[:]
– print(another)

 

  1. Write a program that calculates the percentage of fat calories in food given the calories and fat grams. Details about the formulas and correct results appear in the comments area at the top of the program

The comments show what you should see as output when everything is debugged:

This program demonstrates a solution to the Fat Gram Calculator programming challenge.

      fatCalories = fatGrams * 9

      fatPercentage = fatCalories / calories

When debugged, calories of 100 and fat grams of 10 should display percentage of calories from fat is 90.0%

int calories = 0.0        # Number of calories

int fat_grams = 0.0        # Number of fat grams

int fat_calories = 0.0     # Calories from fat

float fat_percentage = 0.0    Percentage of fat calories

 

#Get the number of calories.

print("How many calories does the food have? ")"

calories = input()

     

#Get the number of fat grams.

fat_grams = ("How many fat grams does the food have? ");

 

#calculate the fatCalorie

fat_grams = fat_calories * 9

     

#Calculate percentage of calories from fat.

fat_percentage = fatCalories / fatGrams;

     

#display the results

print("The percentage of calories from fat is %i%" fat_percentage * 100) + "%.)

 

Submit the debugged DebuggedFatGrams.py file in Canvas under the Exam #1 link.  You need to include the screenshot showing the Python file and correct testing results.

 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE