Chat with us, powered by LiveChat General information/requirements/grading rules This homework tests your knowledge of Functions. So you need to use functions t - Writeedu

General information/requirements/grading rules This homework tests your knowledge of Functions. So you need to use functions t

General information/requirements/grading rules

  1. This homework tests your knowledge of Functions. So you need to use functions to get grades.
  2. Adhere to the naming conventions discussed in class for variable names, program name and function names
  3. Use meaningful names for variables
  4. If there are two words in the variable use first word lowercase and first letter of second wordupper case i.e., firstName or underscore between 2 words i.e first_name
  5. Include appropriate comments in the code
  6. Output should be displayed exactly as mentioned against each problem
  7. Indent the lines of code appropriately
  8. primeNum.py (20 points)

Write a program that displays all of the prime numbers from 1 through 10. The program should have a loop that calls the is_prime function.

Hints:

Declare local variables under main() program

For each number, print whether or not it is prime.

           Write for loop, use range function to loop through the total numbers.

               Call is_prime function 

               print if the number is prime or not prime

        Define is_prime function, 'def is_prime(number):'

            The is_prime function receives a number as an argument, and returns True if number is prime, False otherwise. 

Sample Output:

number      is prime
————————
1      not prime
2      prime
3      prime
4      not prime
5      prime
6      not prime
7      prime
8      not prime
9      not prime
10      not prime

  1. calories.py (25 points)

Write a program that calculates following and display Grams of fat, Fat calories, Grams of carbs, Carb calories in 2 decimal positions.

 the number of calories that result from the fat using formula:

                  Calories from fat = fat grams * 9

the number of calories that result from the carbohydrates using formula:

               Calories from carbs = carb grams * 4

Hints:

Declare local variables under main() program

Prompt the user to enter grams_fat and grams_carbs

Calculate calories from fat

Calculate calories from carbs

Define a function to display resulting calories - 

def showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs):

Note: This function will be called from main()

Sample Output:

If fat grams consumed entered is 87

If carbohydrate grams consumed entered is 39 then the output would be:

Grams of fat:  87.00

Fat calories:  783.00

Grams of carbs:  39.00

Carb calories:  156.00

  1. testscore.py (25 points)

Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score.

Hint:

Declare local variables under main() program

Prompts the user to enter 5 test scores

Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg

Define a function to determine the letter grade: this should accept a test score as argument and return a letter grade based on the following grading scale.

Score         Letter Grades

90-100                A

80-89                   B

70-79                   C

60-69                   D

Below 60            F

Sample Output:

score                   numeric grade   letter grade

—————————————————-

score 1: 99.0                     A

score 2: 78.0                     C

score 3: 68.0                     D

score 4: 99.0                     A

score 5: 89.0                     B

—————————————————-

Average score:  86.6                     B

4. randomGuess.py (30 points)

Write a program that generates a random number in the range of 1 through 20, and asks the user to guess what the number is. 

If the user's guess is higher than the random number, the program should display "Too high, try again".

If the user' guess is lower than the random number, the program should display "Too low, try again".

If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over.

The game continues until the user chooses to quit by entering 0 as input anytime. 

Sample Output:

Enter a number between 1 and 20, or 0 to quit: 14
Too high, try again
Enter a number between 1 and 20, or 0 to quit: 5
Too low, try again
Enter a number between 1 and 20, or 0 to quit: 10
Too low, try again
Enter a number between 1 and 20, or 0 to quit: 13
Congratulations! You guessed the right number!
Enter a number between 1 and 20, or 0 to quit: 10
Too high, try again
Enter a number between 1 and 20, or 0 to quit: 5
Too low, try again
Enter a number between 1 and 20, or 0 to quit: 7
Too low, try again
Enter a number between 1 and 20, or 0 to quit: 9
Congratulations! You guessed the right number!
Enter a number between 1 and 20, or 0 to quit: 0
Thanks for playing!

    Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteEdu. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

    Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

    Do you need an answer to this or any other questions?

    Do you need help with this question?

    Get assignment help from WriteEdu.com Paper Writing Website and forget about your problems.

    WriteEdu provides custom & cheap essay writing 100% original, plagiarism free essays, assignments & dissertations.

    With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.

    Chat with us today! We are always waiting to answer all your questions.

    Click here to Place your Order Now