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]
4 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]4 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
A gas turbine has a thermal efficiency of 20% and develops a power output of 8 MW. Determine the fuel consumption rate if heatin
AlexFokin [52]

Answer:

0.8 kilograms of fuel are consumed each second.

Explanation:

As turbines are steady-state devices, the thermal efficiency of a turbine is equal to the percentage of the ratio of the output power to fluid power, that is:

\eta_{th} = \frac{\dot W}{\dot E} \times 100\,\%

The fluid power is:

\dot E = \frac{\dot W}{\eta} \times 100\,\%

\dot E = \frac{8\,MW}{20\,\%}\times 100\,\%

\dot E = 40\,MW

Which means that gas turbine consumes 40 megajoules of fluid energy each second, which is heated and pressurized with help of the fuel, whose amount of consumption per second is:

50\,\frac{MJ}{kg} = \frac{40\,MJ}{m_{fuel}}

m_{fuel} = 0.8\,kg

0.8 kilograms of fuel are consumed each second.

3 0
3 years ago
A paper clip is made of wire 0.75 mm in diameter. If the original material from which the wire is made is a rod 25 mm in diamete
Bas_tet [7]

Answer:

True strain = 3.7704

Explanation:

Strain is the measure an object that is stretched or deformed. This occurs when a force is applied to an object. Strain deals mostly with the change in length of the object. Strain = Δ L /L = Change in Length over the original Length:

Volume Constancy :

ΔL/L0=A0/ΔA=(D0/ ΔD)=(25mm/0.75mm)^2

ΔL/L0=44.4

Engineering strain:

Engineering strain =ΔL-L0/L0=ΔL/L0-1

Engineering strain =44.4-1=43.4

True strain, ε=In(ΔL/L0)=In(43.4)=3.7704

Note that strain has no unit, so the True strain = 3.7704

8 0
4 years ago
The diesel fuel cooler is being discussed. Technician A says that high-pressure fuel systems generate a lot of heat. Technician
GuDViN [60]

Answer:

Both the technicians are correct.

Explanation:

As the pressure increases the temperature will also increase in accordance with the Boyle's law hence greater amount of heat is formed.

Pressure\propto Temperature

When the temperature increases the intermolecular spaces increase as the molecules of the fuel gain energy and their kinetic energy increases. This is limited to temperatures below dissociation/combustion temperature of diesel .

8 0
3 years ago
Consider a C.T. system in s-plane below. Draw DF1 (Direct Form 1) realization. (by hand) Perform system realization using MATLAB
spin [16.1K]

Answer:

See the attached file for the answer.

Explanation:

See the attached file for the explanation

5 0
3 years ago
Write the following statements as Prolog clauses, in the order given: If it is raining or snowing, then there is precipitation.
Anika [276]

Answer:

a. See Explanation Below

b. No

Explanation:

a.

Interpreting the statements line by line.

First, the prolog clauses need to be initialised, as follows:

:- dynamic freezing/0, precipitation/0, snowing/0, raining/0.

If it is raining or snowing, then there is precipitation.

The statement is splited in two.

1st, if it is raining then there is precipitation

Or

2nd, if it is raining, then there is precipitation.

So, both statements are given as:

precipitation :- raining.

precipitation :- snowing.

If it is freezing and there is precipitation, then it is snowing.

This is a conditional statement that checks if it is freezing AND there's is precipitation.

If true, then it is snowing.

The above statement is given as:

snowing :- freezing, precipitation.

If it is not freezing and there is precipitation, then it is raining.

This is a conditional statement that checks if it is not freezing AND there's is precipitation.

If true, then it is raining.

The not clause is represented as \+

The above statement is the given as:

raining :- \+ freezing, precipitation.

It is snowing.

This is represented as follows

snowing.

So, the full prolog clause is as follows

:- dynamic freezing/0, precipitation/0, snowing/0, raining/0.

precipitation :- raining.

precipitation :- snowing.

snowing :- freezing, precipitation.

raining :- \+ freezing, precipitation.

snowing.

b. What answer does Prolog give to the following queries:

Is it freezing

No

Reason;

All of the conditions above point to raining or snowing; none points to freezing.

Hence, it is no.

8 0
3 years ago
Other questions:
  • The 150-lb man sits in the center of the boat, which has a uniform width and a weight per linear foot of 3 lb>ft. Determine t
    9·1 answer
  • Two parallel Rivers (A and B) are separated by confined and unconfined aquifer estimate the RATE of seepage of river A to River
    15·1 answer
  • Design a circuit with output f and inputs x1, x0, y1, and y0. Let X = x1x0 and Y = y1y0 represent two 2-digit binary numbers. Th
    10·1 answer
  • Intravenous infusions are usually driven by gravity by hanging the bottle at a sufficient height to counteract the blood pressur
    11·1 answer
  • Assuming Stokes behavior, calculate the terminal settling velocity in standard air () for the following particles: (a) diameter
    5·1 answer
  • Assume there exists some hypothetical metal that exhibits ferromagnetic behavior and that has (1) a simple cubic crystal structu
    6·1 answer
  • Please answer ASAP!!
    8·2 answers
  • What are the causes and solutions of social problems ?what are the causes and solutions of social problems ​
    15·1 answer
  • Cat is stuck in 10 foot hole how do i get it unstuck
    13·2 answers
  • A linear frequency-modulated signal makes a good test for aliasing, because the frequency moves over a range. This signal is
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!