PYTHON CODE:
# getting the number of cities
n=int(input('Enter number of cities(n): '))
# empty list to store the cities,temperature
cities=[]
temperature=[]
# looping through the number of cities
for i in range(n):
# getting the temperature and city name from
the user
user_inp=input('\nEnter name and temperature of
city {0}: '.format(i+1))
# splitting the user input by space
t=user_inp.split()
# adding the city name to the cities
list
cities.append(t[0])
# adding the temperature to the temperature
list after converting to float
temperature.append(float(t[1]))
# finding the average temperature
avg_temperature=sum(temperature)/len(temperature)
# printing the average temperature
print('\nThe average temperature is
{0:.3f}'.format(avg_temperature))
# printing the above temperature and the corresponding city
name
print('\nCities with temperature above average are:')
# looping through the temperature list
for t in range(n):
# checking for above average
temperature
if temperature[t] > avg_temperature:
# printing the city
and temperature
print('{0:20s}
{1:.1f}'.format(cities[t],temperature[t]))
print('\nCities with temperature below average are:')
# looping through the temperature list
for t2 in range(n):
# checking for below average
temperature
if temperature[t2] < avg_temperature:
# printing the city
and temperature
print('{0:20s}
{1:.1f}'.format(cities[t2],temperature[t2]))
SCREENSHOT FOR CODING:
SCREENSHOT FOR OUTPUT:
plz solve it using ( python) spyder. use lists, loops,,,etc not allowed( def, ...) Exercise 1...
i need help using python ( spyder) only use files , loops if needed is statement do not use , def function or any other. Exercise 1: Daily temperature is recorded for some weeks in files (templ.txt", temp2.txt, and temp3.txt; provided in the MOODLE). The first line contains number of weeks and the rest of the lines each represent the week number followed by temperature on the seven days of that week (see samples input files below). Write a python...
please do a and b Lab Exercise 9 Assignment Overview This lab exercise provides practice with dictionaries of lists and sets in Python. A. Write a program using Dictionaries of lists Consider the file named "lab9a.ру" Given two files named exactly continents. txt and cities.txt (no error checking of the file name is needed) of continents, countries and cities. Write a program to read continents, countries and their cities, put them in a nested dictionary and print them (no duplicates...
Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys() member function that returns a list of a dictionary's keys. You can check if a particular key is in a dictionary by using the in test with the keys list. For example, if our dictionary is MyDict = { 1: 'One', 2: 'Two', 3: 'Three' } Then ( 2 in MyDict.keys() ) evaluates to True, indicating that 2 is a valid key for MyDict....
SOLVE IN PYTHON: Exercise #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns true (Boolean type) if the arrays store same values in the...
Python Testing a) The temperature readings are correctly handled using a while loop and the output is correct b) The wind speed readings are correctly handled using a while loop and the output is correct c) The humidity readings are correctly handled using a while loop and the output is correct d) Works correctly overall The program first prompts for and reads in temperatures (all integers), until a line with no characters in received. It computes the average of all...
Please help with PYTHON exercise 1 below: Write a program Sores.py to process a student's homework scores. Ask user to enter the homework scores for a student and save the scores in a list. Loop through the list to find the total score and the lowest score. (Do not use built-in function, sum and min. You need to write a loop to process the scores). Calculate the raw average score and modified average score (after dropping the lowest score). Print...
ENGR 200 FALL 2019 P8: TEMPERATURE ANALYSIS (input/output files, if structures, for loops, two-dimensional array, one-dimensional character array) DUE: November 14, 2019, at 11:59 p.m. US Central Time POINTS: 70 INTRODUCTION: You are working on development of a new power plant for Centerville, USA. Average monthly temperature data has been collected as part of designing the new power plant, and you are required to develop a computer program that will perform averaging analysis. The input data file is called temp....
Hi. Please help me solve this in python using only while loops, if statements. Can't use for loops and lists. In this programming assignment, you will be writing a program that prints out several shapes via text. In this PA, you will be required to use functions and parameters. This is both to reduce redundancy and to make your code clean and well-structured. Name your program shaper.py Your program should have the capability to print out three different shapes: An...
Use python Start: def main(): gradeList = [] fileName = getFile() gradeList = getData(fileName) mean = calculateMean(gradeList) sd = calculateSD(mean, gradeList) displayHeadings(gradeList, mean, sd) curveGrades(mean, sd, gradeList) if __name__ == "__main__": main() For this program, you will create a grade curving program by reading grades from a file, calculating the mean and standard deviation. The mean is the average value of the grades and the standard deviation measures the spread or dispersal of the numbers from the...
python 11.8 Multiple committees The eventual goal of this assignment is to compute the total number of ways of forming a collection of committees from an academic department of n professors. The first task is to write a function called committee to compute the number of ways of forming a single committee with members from a collection of n people. This is the same as compușing the number of ways of choosing r people out of n to sit at...