1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alika [10]
3 years ago
7

You want to know your grade in Computer Science, so write a program that continuously takes grades between 0 and 100 to standard

input until you input "stop", at which point it should print your average to standard output. Instructor Notes: Make sure to initialize counter and total to 0 Read the grades between 0 and 100: grade = input() Use while loop as long as the grades input is not equal to "stop" Make sure to total int(grades) Increment counter by one input the grade again Finally, print the average: total/counter
Engineering
1 answer:
Margarita [4]3 years ago
5 0

Answer:

The code is given below in python

# Code Block 1

count = 0  # count variable

total = 0  # total variable

enter = '' # input variable

while enter != 'stop':

   enter = input('Enter a grade:' )

   if enter != 'stop' and enter.isdigit():

       total += int(enter) # add to total value

       count = count + 1   # then to the count

print float(total) / count

# Code Block 2

numbers = []

while enter != 'stop':

   enter = input('Enter a grade:' )

   if enter != 'stop':

       numbers.append(int(enter))

print sum(numbers) / float(len(numbers))

You might be interested in
A sheet of steel 4.4 mm thick has nitrogen atmospheres on both sides at 1200°C and is permitted to achieve a steady-state diffus
VARVARA [1.3K]

Answer:

0.544×10–³

Explanation:

Please see the attached file for the solution

7 0
3 years ago
What could happen in the aviation
Alina [70]

Answer:

Yes

Explanation:

7 0
2 years ago
What are the two safety precautions taken before driving a car​
nydimaria [60]

<em>Answer:</em>

<h3><em>1. Check mirrors</em></h3><h3><em>2. Put on your seat belt</em></h3>

<em>Explanation:</em>

<em>1. Checking your mirrors are very important because if someone screwed with them then it can mess up your driving. </em>

<em />

<em>2. Putting on your seat belt is a law so you must put it on and it can save your life one day. </em>

7 0
3 years ago
You live on a street that runs East to West. You just had 2 inche of snow and you live on the North side of the street. You retu
RSB [31]

Answer:

The heat from the sun melted it

Explanation:

If the street runs east to west, houses on the south (across the street) will project shadows on their sidewalk, while the northern sidewalk will be illuminated. This is for the northern hemisphere, on the southern hemisphere it would be the other way around.

5 0
2 years ago
Remember from Lab 3C that Mad Libs are activities that have a person provide various words, which are then used to complete a sh
Harlamova29_29 [7]

Answer:

Python code is explained below

Explanation:

CODE(TEXT): -

9A.py:-

def sentence(): #function to read input and display

  name = input("Enter a name: ") #input name

  place = input("Enter a place: ") #input place

  number = int(input("Enter a number: ")) #input number typecasted to int

  noun = input("Enter a plural noun: ") #input plural noun

  adjective = input("Enter an adjective: ") #input adjective

  print("\n{} went to {} to buy {} different types of {}".format(name, place, number, noun)) #format is used to display o/p

  print("but unfortunately, the {} were all {} so {} went back to {} to return them.\n".format(noun, adjective,name, place))

op = "n" #initially op = n i.e. user not wanting to quit

while op != "y" : #while user does not input y

  sentence() #input words from user

  op = input("Do you want to quit [y/n]? ") #prompt to continue or quit

  if op == "y": #if yes then print goodbye and exit

      print("Goodbye")

      break

  else: #else print newline and take input

      print("")

9B.py: -

#inputs are strings by default applying a split() function to a string splits it into a list of strings

#then with the help of map() function we can convert all the strings into integers

numbers = list(map(int, input("Enter the input: ").split()))

sum = 0 #sum is initially 0

for i in range(len(numbers)): #loops for all the elements in the list

  sum = sum + numbers[i] #add the content of current element to sum

avg = sum/ len(numbers) #average = (sum of all elements)/ number of elements in the list

max = numbers[0] #initially max = first number

for i in range(1, len(numbers)): #loops for all remaining elements

  if numbers[i] > max : #if their content is greater than max

      max = numbers[i] #update max

print("The average and max are: {:.2f} {}".format(avg, max)) #format is used to print in formatted form

#.2f is used to print only 2 digits after decimals

9C.py: -

#inputs are strings by default applying a split() function to a string splits it into a list of strings

#then with the help of map() function we can convert all the strings into integers

numbers = list(map(int, input("Enter a list of numbers: ").split()))

numbers = [elem for elem in numbers if elem >= 0] #using list comprehension

#loops for all elements of the list and keep only those who are >= 0

numbers.sort() #list inbuilt function to sort items

print("The non-negative and sorted numbers are: ", end = "")

for num in numbers: #for all numbers in the list print them

  print("{} ".format(num), end = "")

7 0
3 years ago
Other questions:
  • A series R-L circuit is given. Circuit is connected to an AC voltage generator. a) Derive equations for magnitude and phase of c
    13·1 answer
  • An air-standard cycle with constant specific heats at room temperature is executed in a closed system with 0.003 kg of air and c
    15·1 answer
  • Aerospace engineers who work for certain government agencies are often required to have security clearance. Explain two reasons
    9·1 answer
  • Plz answer all of these questions!
    15·1 answer
  • Buying shop supplies from the shop owner to work on your own car at home is an ethical practice.
    14·1 answer
  • The two pond system is fed by a stream with flow rate 1.0 MGD (million gallons per day) and BOD (nonconservative pollutant) conc
    15·1 answer
  • Who is using welding symbols to to communicate the detailed information necessary for welders to complete the weld?
    6·1 answer
  • Is a street the same as a avenue
    10·2 answers
  • Example 12: Write an algorithm and draw a flowchart to calculate
    12·1 answer
  • From the top of a vertical cliff 80m high, the angles of depression of 2 buoys lying due west of the cliff are 23° and 15° respe
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!