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 cast-iron tube is used to support a compressive load. Knowing that E 5 10 3 106 psi and that the maximum allowable change in l
Papessa [141]

Answer:

(a) 2.5 ksi

(b) 0.1075 in

Explanation:

(a)

E=\frac {\sigma}{\epsilon}

Making \sigma the subject then

\sigma=E\epsilon

where \sigma is the stress and \epsilon is the strain

Since strain is given as 0.025% of the length then strain is \frac {0.025}{100}=0.00025

Now substituting E for 10\times 10^{6} psi then

\sigma=(10\times 10^{6} psi)\times 0.00025=2500 si= 2.5 ksi

(b)

Stress, \sigma= \frac {F}{A} making A the subject then

A=\frac {F}{\sigma}

A=\frac {\pi(d_o^{2}-d_i^{2})}{4}

where d is the diameter and subscripts o and i denote outer and inner respectively.

We know that 2t=d_o - d_i where t is thickness

Now substituting

\frac {\pi(d_o^{2}-d_i^{2})}{4}=\frac {1600}{2500}

\pi(d_o^{2}-d_i^{2})=\frac {1600}{2500}\times 4

(d_o^{2}-d_i^{2})=\frac {1600}{2500\times \pi}\times 4

But the outer diameter is given as 2 in hence

(2^{2}-d_i^{2})=\frac {1600}{2500\times \pi}\times 4

2^{2}-(\frac {1600}{2500\times \pi}\times 4)=d_i^{2}

d_i=\sqrt {2^{2}-(\frac {1600}{2500\times \pi}\times 4)}=1.784692324 in\approx 1.785 in

As already mentioned, 2t=d_o - d_i hence t=0.5(d_o - d_i)

t=0.5(2-1.785)=0.1075 in

3 0
4 years ago
3. (9 points) A square-thread power screw is used to raise or lower the basketball board in a gym, the weight of which is W = 10
Bezzdna [24]

Answer:

a) 49.95 watts

b) The self locking condition is satisfied

Explanation:

Given data

weight of the square-thread power screw ( w ) = 100 kg = 1000 N

diameter (d) = 20 mm ,

pitch (p) = 2 mm

friction coefficient of steel parts ( f ) = 0.1

Gravity constant ( g ) = 10 N/kg

Rotation of electric power screwdrivers = 300 rpm

A ) Determine the power needed to raise to the basket board

first we have to calculate T

T = Wtan (∝ + Ф ) * \frac{Dm}{2} ------------- equation 1

Dm = d - 0.5 ( 2) = 19mm

Tan ∝ = \frac{L}{\pi  Dm}  where L = 2*2 = 4

hence ∝ = 3.83⁰

given f = 0.1 , Tan Ф = 0.1.     hence Ф = 5.71⁰

insert all the values into equation 1

T = 1.59 Nm

Determine the power needed using this equation

\frac{2\pi NT }{60}   =  \frac{2\pi * 300 * 1.59}{60}

= 49.95 watts

B) checking if the self-locking condition of the power screw is satisfied

Ф > ∝  hence it is self locking condition is satisfied

3 0
3 years ago
To water his lawn, a homeowner uses two hoses. One connects to the faucet, the other to the end of the first hose to make the ho
Shtirlitz [24]

Answer: to be exact you need 28mm of tubing for that

Explanation:

When the election

8 0
4 years ago
Write a Python program that does the following. Create a string that is a long series of words separated by spaces. The string i
dybincka [34]

Answer:

The code is attached.

Explanation:

I created a string s including 6 colors with spaces in between. Then I converted the string into a list x by using split() method. I used three different methods for removing elements from the list. These methods are remove(), pop() and del.

\\ Then I used methods append(), insert() and extend() for adding elements to the list.

\\ Finally I converted list into a string using join() and adding space in between the elements of the list.

4 0
4 years ago
A 200-mm-long strip of metal is stretched in two steps, first to 300 mm and then to 400 mm. Show that the total true strain is t
Neko [114]

Explanation:

For true Strain:

step 1:

E true = Ln(1 + 0.5 ) = 0.40

Step 2:

E true = Ln(1 + 0.33 ) = 0.29

By single step process:

E true = Ln(1 + 1 ) = 0.69

total strain of step process = 0.40 + 0.29 = 0.69 units

SO TRUE STRAIN IS ADDITIVE.

4 0
3 years ago
Other questions:
  • A forklift raises a 90.5 kg crate 1.80 m. (a) Showing all your work and using unity conversion ratios, calculate the work done b
    14·2 answers
  • What is the zone that has just been added to the exchange zone where athletes may now hand off the baton
    5·1 answer
  • The head difference between the inlet and outlet of a 1km long pipe discharging 0.1 m^3/s of water is 0.53 m. If the diameter is
    11·1 answer
  • what should be used to feed material into a machine? A.joy stick B.push stick C. your feet D. your hands​
    14·1 answer
  • For the following three (3) questions, assume that the link layer uses the flag bytes with byte stuffing approach for framing, w
    15·1 answer
  • Which of the following are made up of electrical probes and connectors?
    8·1 answer
  • My t!t$ feel sore and heavyy
    13·1 answer
  • TP-6 What should you do when fueling an outboard boat with a portable tank?
    12·1 answer
  • A wing generates a lift L when moving through sea-level air with a velocity U. How fast must the wing move through the air at an
    7·1 answer
  • The Imager for Mars Pathfinder (IMP) is an imaging system. It has two camera channels. Each channel has color capability. This i
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!