CSCI 131 – Python Language



CSCI 131 – Python Language

Functions Practice

Problem 1:

In file minimum.py write a function min (num). The function reads the sequence of num numbers and finds and returns the minimal value among the input numbers.

Write a main program that reads one input number that indicates the amount of numbers in the input sequence. The main program uses function min to find the minimal value among the input numbers.

Problem 2: (problem 1 from your text book from Programming Assignment 5)

In a file weather.py write a function FahToCel( Fah) that converts Fahrenheit to Celsius and returns the correspondent Celsius temperature. Write a main program that asks user for 7 days forecast and finds the average Celsius temperature for this 7 days.

Problem 3: (problem 3 from your text book from Programming Assignment 5)

In a file travel.py write a function speed(distance, time) that calculates and returns the average speed of the car if the car traveled “distance” miles and “time” hours.

Write a main program that asks user to enter pairs of positive numbers, the first zero indicates the end of the input. For each pair the program calculates the average speed using the function speed. Each pair will be considered as distance and travel time in hours.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download