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...
(PYTHON) prompt the user to enter a single-digit num and print that num as follow: 1)...
(PYTHON) prompt the user to enter a single-digit num and print that num as follow: 1) use loops 2) print num in words. Example: 5 is 'five' 3) the number of spaces that go back and forth should equal the num if the user inputs 5, the program prints: five . . . . .five five . . . . . five five and 2 would be: two . .two (the periods(.) are only for demonstration purposes. Don't include it...
Python Code: Write a program to prompt the user to enter a first name, last name,...
Python Code: Write a program to prompt the user to enter a first name, last name, student ID, number of hours completed and GPA for 5 students. Use a loop to accept the data listed below. Save the records in a text file. Write a second program that reads the records from your new text file, then determines if the student qualifies for Dean’s list or probation. Display the records read from the file on screen with appropriate headings above...
Write a C program Your program will prompt the user to enter a value for the...
Write a C program Your program will prompt the user to enter a value for the amount of expenses on the credit card. Retrieve the user input using fgets()/sscanf() and save the input value in a variable. The value should be read as type double. The user may or may not enter cents as part of the input. In other words, expect the user to enter values such as 500, 500.00 and 500.10. The program will then prompt the user...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT