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
nata0808 [166]
3 years ago
11

Remember from Lab 3C that Mad Libs are activities that have a person provide various words, which are then used to complete a sh

ort story in unexpected (and hopefully funny) ways. Extend your program from Lab 3C that repeats asking the user for input and displaying the short story until the user wants to quit. Enter a name: Eric Enter a place: Lou & Harry's Enter a number: 12 Enter a plural noun: cars Enter an adjective: orange Eric went to Lou & Harry's to buy 12 different types of cars but unfortunately, the cars were all orange so Erie went back to Lou & Harry's to return them. Do you want to quit ly/n)? Enter a name: Derek Enter a place: JoAnn Fabrics and Crafts Enter a number: 3 Enter a plural noun: sewing machines Enter an adjective: pretty Derek went to JoAnn Fabrics and Crafts to buy 3 different types of sewing machines but unfortunately, the sewing machines were all pretty so Erie 'went back to JoAnn Fabric and Crafts to return them. Do you want to quit ty/n)? y Goodbye ACTIVITY 16 25.1: LAB 9A Mad Lib - Loop 0120 U MacBook Pro 16.26 LAB 9B: Varied Amount of Input Data Overview Create a program that can manipulate data in a list. Objectives To be able to get input from the user on one line, modify the data type, and perform mathematical operations on the data. Description Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers on a single lineas Input, and output the average (as a float with 2 decimal points) and the max. When you output the average, you must use the formato method or you will not pass one of the test cases Hint remember that the input comes in as a single string: you need to get each token of the string and create a list of integers instead Section 9.7 has an example of this Ex If the input is Enter the input: 15 2005 the output is The average and max are: 10.00 20 if the input is: Enter the input: 12 10 15 20 25 22 14 18 20 20 the output is The average and max are: 17.60 25 16.27 LAB 9C: Filter and Sort a List Overview Be able to remove and sort items in a list Objectives To understand how to populate a list, remove certain items from a list, sort a list, and display the contents of a list Description Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest). Zero is considered a non-negative integer EX Enter a list of numbers: 10 -7 4 39 -6 12 2 The non-negative and sorted numbers are: 2 4 10 12 39 For coding simplicity, follow every output value by a space. Do not end with newline ACTIVITY 1627.1: LAB 9C: Filter and Sort a List 0/25 main.py Load default template. 1 " Type your code here."
Engineering
1 answer:
Harlamova29_29 [7]3 years ago
7 0

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 = "")

You might be interested in
In some synchronizer applications, the clock frequency f is substituted for the parameter a in metastability MTBF calculations,
Contact [7]

Answer:

Please see the attached file for the complete answer.

Explanation:

Download pdf
4 0
3 years ago
Which of the following team members would not be involved in the design of
dimulka [17.4K]

Answer:

Writer

Explanation:

5 0
2 years ago
Your family has asked you to estimate the operating costs of your clothes dryer for the year. The clothes dryer in your home has
trasher [3.6K]

Answer:

The costs to run the dryer for one year are $ 9.03.

Explanation:

Given that the clothes dryer in my home has a power rating of 2250 Watts, and to dry one typical load of clothes the dryer will run for approximately 45 minutes, and in Ontario, the cost of electricity is $ 0.11 / kWh, to calculate the costs to run the dryer for one year the following calculation must be performed:

1 watt = 0.001 kilowatt

2250/45 = 50 watts per minute

45 x 365 = 16,425 / 60 = 273.75 hours of consumption

50 x 60 = 300 watt = 0.3 kw / h

0.3 x 273.75 = 82.125

82.125 x 0.11 = 9.03

Therefore, the costs to run the dryer for one year are $ 9.03.

8 0
2 years ago
what is called periodic function give example? Plot the output which is started with zero degree for one coil rotating in the un
marta [7]

Answer:

A periodic function is a function that returns to its value over a certain period at regular intervals an example is the wave form of flux density (B) = sin <em>wt</em>

Explanation:

A periodic function is a function that returns to its value over a certain period at regular intervals an example is the wave form of flux density (B) = sin <em>wt</em>

attached to the answer is a free plot of the output starting with zero degree for one coil rotating in a uniform magnetic field

B ( wave flux density ) = Bm sin<em>wt  and w = </em>2\pif = \frac{2\pi }{T} rad/sec

3 0
2 years ago
Troy must keep track of the amount of refrigerant he uses from a 50-pound cylinder to ensure that accurate
IgorLugansk [536]

Answer:

Amount of gas still in cylinder = 28 pound

Explanation:

Given:

Amount of gas in cylinder = 50 pound

Amount of gas used in Ms. Jones system = 13 pound

Amount of gas used in client system = 9 pound

Find:

Amount of gas still in cylinder

Computation:

Amount of gas still in cylinder = Amount of gas in cylinder - Amount of gas used in Ms. Jones system - Amount of gas used in client system

Amount of gas still in cylinder = 50 - 13 - 9

Amount of gas still in cylinder = 28 pound

7 0
3 years ago
Other questions:
  • 1. Copy the file Pay.java (see Code Listing 1.1) from the Student CD or as directed by your instructor. 2. Open the file in your
    10·1 answer
  • Choose the best data type for each of the following so that any reasonable value is accommodated but no memory storage is wasted
    5·1 answer
  • A piston-cylinder device contains 0.8 kg of steam at 300°C and 1 MPa. Steam is cooled at constant pressure until one-half of the
    9·1 answer
  • Arc blow typically occurs in steel and metals that contain iron.<br> True or false
    7·2 answers
  • An apple, potato, and onion all taste the same if you eat them with your nose plugged
    8·2 answers
  • An air conditioning system is to be filled from a rigid container that initially contains 5 kg of saturated liquid at 24° Celsiu
    14·1 answer
  • The most important rating for batteries is the what
    11·1 answer
  • Define Mechanism and mechanics.​
    15·2 answers
  • Oil, with density of 900 kg/m3 and kinematic viscosity of 0.00001 m2/s, flows at 0.2 m3/s through 500 m of 200-mm-diameter cast-
    12·1 answer
  • Key term of Bimetal strip
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!