Question

In: Computer Science

Answer using Jupyter Python #Prompt the user to enter a passing grade and store the value...

Answer using Jupyter Python #Prompt the user to enter a passing grade and store the value from #the input() into a variable. #Refer to the variable in problem 2 to complete the following: #Use the if statement to evaluate the only the first element in the #grades list using index notation. #If the grade is passing, display PASSED, otherwise display FAILED. """Problem 1d""" #Use the for statement to iterate on each element in the #grades list (from problem 1a) and displays each value. #Specifically, for each grade in the grades list, if the grade is #passing (referring to problem 1b), then display PASSED, otherwise display FAILED. """Problem 2a""" #Create a function that will evaluate if each grade in a list is considered #passing or failing. [hint: use the for statement and if...else together] #Store the total number of passing and failing grades in their own respective variables. #The function should return a dictionary with two key-value pairs where the keys are # the words PASSED and FAILED mapped to their total counts variable. """Problem 2b""" #Call the function and pass in the grades list (from problem 1a) as an argument.

Solutions

Expert Solution

As per your requirement, here is the Python code:

Rawcode:

#asking user to enter passing grade and storing it in variable

passing = int(input("Enter a passing grade: "))

#problem 1a

#creating grades list

grades = [20, 50, 43, 56, 67, 23, 96, 41, 85, 73, 43, 25, 43]

#Using the if statement to evaluate the only the first element in the #grades list using index notation.

if(grades[0] is passing):

    print("PASSED")

else:

    print("FAILED")

#problem 1b

#Using the for statement to iterate on each element in the #grades list (from problem 1a) and displays each value.

for i in grades:

    print(i)

    # if the grade is #passing (referring to problem 1b), then display PASSED

    if(i is passing):

        print("PASSED")

    #otherwise display FAILED.

    else:

        print("FAILED")

#Creating a function that will evaluate if each grade in a list is considered #passing or failing

def gradeCount(grades):

    #creating an empty dictionary

    countDict = dict()

    #initializing passed count

    passCount = 0

    #initializing failed count

    failCount = 0

    #looping through grades list

    for i in grades:

        #checking if they are passing

        if(i is passing):

            #then incrementing pass count

            passCount = passCount + 1

        #if it they are failed

        else:

            #then incrementing fail count

            failCount = failCount + 1

    #mapping passCount value to key PASSED

    countDict['PASSED'] = passCount

    #mapping failCount value to key FAILED

    countDict['FAILED'] = failCount

    #returns dictionary of count of both passed and failed

    return countDict

#Calling the function and pass in the grades list (from problem 1a) as an argument.

print(gradeCount(grades))

Here is the screenshots of source code:

Here is the screenshot of output:

Hope this helps you. Please feel free to ask if you still have any queries.

Do upvote. Thank you !


Related Solutions

Answer using Jupyter Python #Prompt the user to enter a passing grade and store the value...
Answer using Jupyter Python #Prompt the user to enter a passing grade and store the value from #the input() into a variable. #Refer to the variable in problem 2 to complete the following: #Use the if statement to evaluate the only the first element in the #grades list using index notation. #If the grade is passing, display PASSED, otherwise display FAILED. """Problem 1d""" #Use the for statement to iterate on each element in the #grades list (from problem 1a) and...
*******************In Python please******************* (1) Prompt the user to enter a string of their choosing. Store the...
*******************In Python please******************* (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer...
Prompt the user to enter an integer Then, prompt the user to enter a positive integer n2. Print out all the numbers that are entered after the last occurrence of n1 and whether each one is even or odd If n1 does not occur or there are no values after the last occurrence of n1, print out the message as indicated in the sample runs below. Sample: Enter n1: -2 Enter n2: 7 Enter 7 values: -2 3 3 -2...
Prompt the user for their name, get and store the user input. Prompt the user for...
Prompt the user for their name, get and store the user input. Prompt the user for their age, get and store the user input. We will assume that the user will enter a positive integer and will do no error checking for valid input. Determine and store a movie ticket price based on the user's age. If their age is 12 or under, the ticket price is $5. If their age is between 13 and 64, inclusive, the ticket price...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in...
C++ Code Writing prompt: Grade Calculation: Write a program that asks the user to enter in a number greater than or equal to zero and less than or equal to 100. If they do not you should alert them and end the program. Next, determine the letter grade associated with the number. For example, A is any grade between 90 and 100. Report the letter grade to the user.
C code please (1) Prompt the user to enter a string of their choosing. Store the...
C code please (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and...
8.30 LAB*: Program: Authoring assistant. PYTHON PLEASE!! (1) Prompt the user to enter a string of...
8.30 LAB*: Program: Authoring assistant. PYTHON PLEASE!! (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be...
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in...
(1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's numbers on one line, each number followed by one space. (2 pts) Ex: Enter weight 1: 236.0 Enter weight 2: 89.5 Enter weight 3: 142.0 Enter weight 4: 166.3 Enter weight 5: 93.0 You entered: 236.0 89.5 142.0 166.3 93.0 (2) Also output the total weight, by summing the array's elements. (1 pt) (3) Also output the...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
Write a program using the switch statement to calculate geometric quantities. Prompt the user to enter...
Write a program using the switch statement to calculate geometric quantities. Prompt the user to enter a radius. Then present a menu of choices for quantities to be calculated from that radius:                         A         Area of a Circle                         C         Circumference of a Circle                         S          Surface Area of a Sphere                         V         Volume of a Sphere Prompt the user to enter the character corresponding to the quantity to be calculated. Use a switch statement to handle the calculations. Use...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT