Please add notes to the following #Python script to help the novice user communicate with the program:
s = input('Enter space separated integers: ')
lst = [int(x) for x in s.split(" ")]
avg = 0
if(len(lst)>2):
lst.sort()
for x in lst[2:]:
avg += x
avg = avg / (len(lst)-2)
print("Average =",avg)
#Reading a line of string from user
s = input('Enter space separated integers: ')
#splitting the string based on space and converting the each splitted value to integer using int()
lst = [int(x) for x in s.split(" ")]
#Defining avg and assigning 0 to it
avg = 0
#Checking that user enters more than 2 numbers
if(len(lst)>2):
#Sorting the numbefrs entered by user
lst.sort()
#lst[2:] trims the first 2 values in the list
#This means removing 2 least enties in the list
for x in lst[2:]:
#Calculating sum
avg += x
#Calculating average using sum
avg = avg / (len(lst)-2)
#printing avg
print("Average =",avg)
Please add notes to the following #Python script to help the novice user communicate with the...
Complete the Python program below that performs the following operations. First prompt the user to input two integers, n and m. If n<m, then print the odd positive integers that are less than m (in order, on a single line, separated by spaces). If man, then print the even positive integers that are less than n (in order, on a single line, separated by spaces). If neem, then print nothing. For instance, if the user enters 5 followed by 10,...
Directions: Write a code for the following programming exercise in PYTHON!!!!!!! -Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Here is what i got so far, but for some reason this code only print the Minimum and Maximum. its not printing the Average. def...
Python Error: Writing a program to complete the following: Prompt the user for the name of an input file. Open that file for input. (reading) Read the file using a "for line in a file" loop For each line, o print the line and compute and print the average word length for that line. Close the input file Sample output: MY CODE IS WRONG AND NEED HELP CORRECTING IT!!! ------------------------------------------------------------------------------------------------------------------------ DESIRED OUTPUT: Enter input file name: Seasons.txt Thirty days hath September...
I need help with this python programming exercise, please!
thanks in advance
Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...
write in python Create a program that will ask the user for a list of integers, all on one line separated by a slash. construct a list named "adj_numbers" which contains the users input numbers after subtracting 2 from each number. then print the resulting list. the input statement and print statement are given to you in the starting code. a sample run of the program is as follows: Enter a list of integers, separated by slashes: 7/3/6/8 resulting list:...
Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...
Python Script format please!
1. Write a script that takes in three integer numbers from the
user, calculates, and displays the sum, average, product, smallest,
and largest of the numbers input. Important things to note: a. You
cannot use the min() or max() functions, you must provide the logic
yourself b. The calculated average must be displayed as an integer
value (ex. If the sum of the three values is 7, the average
displayed should be 2, not 2.3333). Example:...
Write a python program that repeatedly asks the user to input a pair of integers. The program should record the largest number of each pair into a list. The program should keep asking the user to input pairs of numbers until the user enters -1 for the first number. At this point the program should print the list on a single line, with each value separated by a space and then stop. Example of expected behaviour: Please enter first number:...
You are writing a Python script that prompts a user to guess the
current contents of a variable called temperature (assume
previously set, and not shown). What is the missing statement?
guess = float(input("Please enter your guess "))
____________________________ # Fill in the
missing line of code
print ("You're right!")
else:
print ("Please try again")
You are writing a Python script that prompts a user to guess the current contents of a variable called temperature (assume previously set,...
Intro to Python:
Q1:
Bonnie is writing a Python program for her math class so she can
check her answers quickly. She is having some difficulties,
however, because when she enters values like 3.5 or 2.71 her
program throws an error. She has heard of your expertise in Python
and asks for your help. What error is being thrown and how can she
fix the program to accept values like 3.5 or 2.71?
from math import sgrt def distance (coorl,...