Question

In: Computer Science

#Python program using loop instead of numpy or pandas. Write a function to enter n student...

#Python program using loop instead of numpy or pandas.
Write a function to enter n student scores from 0 to 100 to represent student score,
Count how many A (100 - 90), B(89-80), C(79-70), D(69-60), F(<60)
We will use numpy array OR pandas later for this problem, for now use loop

Invoke the function with 10 student scores, show the result as follow:

Test
Enter 10 scores
Enter  a student score: 99
Enter  a student score: 88
Enter  a student score: 77
Enter  a student score: 66
Enter  a student score: 55
Enter  a student score: 90
Enter  a student score: 80
Enter  a student score: 70
Enter  a student score: 60
Enter  a student score: 50

Grades : 
As :  2
Bs :  2
Cs :  2
Ds :  2
Fs :  2

Solutions

Expert Solution

CODE -

# Initializing the number of student scores to 10

n = 10

# Initializing the no. of students in each category of grade to 0

count_A = 0

count_B = 0

count_C = 0

count_D = 0

count_F = 0

print("Enter 10 scores")

# Iterating for no. of scores times

for i in range(n):

    # Asking user for score

    score = int(input("Enter a student score: "))

    # Increasing the count of student in a grade category if score lies in that grade

    if score>=90 and score<=100:

        count_A += 1

    if score>=80 and score<=89:

        count_B += 1

    if score>=70 and score<=79:

        count_C += 1

    if score>=60 and score<=69:

        count_D += 1

    if score<60:

        count_F += 1

# Displaying the result

print("\nGrades:")

print("As:", count_A)

print("Bs:", count_B)

print("Cs:", count_C)

print("Ds:", count_D)

print("Fs:", count_F)

SCREENSHOTS -

CODE -

OUTPUT -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

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...
Using Python coding language (with or without Pandas and/or NumPy), 1. Can you define function sleep...
Using Python coding language (with or without Pandas and/or NumPy), 1. Can you define function sleep to tell whether the participant are of the ages through 18 to 60 and sleep less than 6 hours per day? 2. Develop codes to check whether the sleep function you defined can make correct judgement. Make sure you write comments or create informative vairable name so that I can understand how you check the sleep function. (Hints: You can create toy data/dataframe to...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data...
I'm working on a scatter-plot program in Python using Pandas, Matplotlib, Numpy, etc. I'm pulling data from a CSV file, which has no names, just numbers. All I did was to read a .csv file. How do I pull data from three columns which contains about 1500 rows with just numbers and make a scatter plot with two in the x-axis and the third in the y-axis?
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. 2. Write a python program using Pandas to convert a Panda module Series to Python list and print it's type. (Hint: use ds.tolist() to convert the pandas series ds to a list) 3. Create a pandas dataframe called **my_df** with index as integer numbers between 0 to 10, first column (titled "rnd_int") as 10 integer random numbers between...
Complete the following in syntactically correct Python code. Write a program, using a for loop, that...
Complete the following in syntactically correct Python code. Write a program, using a for loop, that calculates the amount of money a person would earn over a period of time if his or her salary is 1 penny for the first day, 2 pennies for the second day, 4 pennies for the third day, and continues to double each day. 1.      The program should ask the user for the number of days the employee worked. 2.      Display a table showing the salary...
11) Enter the following using Java. Use for loop to enter student id, student name, major...
11) Enter the following using Java. Use for loop to enter student id, student name, major and grades. Also grades should display their letter grades based on their conditions. After that display the name of students and their info, and also their letter grade After that display the sum of all grades and the average Output Example: Student ID: 0957644 Student Name: Pedro Hernandez Student Major: Business Information Systems Grades for Fall 2020: Introduction to Computer Science using Java: 85,...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
USING PYTHON. Thank you in advance Write a program that allows the user to enter a...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a series of string values into a list. When the user enters the string ‘done’, stop prompting for values. Once the user is done entering strings, create a new list containing a palindrome by combining the original list with the content of the original list in a reversed order. Sample interaction: Enter string: My Enter string: name Enter string: is Enter string: Sue Enter string:...
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user...
(using for loop, parameters, if, else condition only )Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message...
write a program bus management system? using: if else, for loop, do while loop, function, arrays,...
write a program bus management system? using: if else, for loop, do while loop, function, arrays, string, structure
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT