Question: E 1 0 1 Fall 2 0 2 4 Exam 1 6 . ) ( 1 5 points ) Write a Python program that defines

E101 Fall 2024
Exam 1
6.)(15 points) Write a Python program that defines a function named cm2in. This function takes one float as a parameter and returns a float. The parameter is the length in
centimeters. The function converts the length to inches by dividing it by 2.54. The function then returns this value. The program should prompt the user for the length in centimeters, call the cm2in function to convert the length to inches, and then print the value returned from the function.
10/14/2024
Example Output:
Enter the length in centimeters: 8.5
3.34646 inches
def (aco Cepatk)
orgi - Top flocr (pd p .")
teslt length
beturn yesult
priot (Vesult )
E101 Fall 2024
Exam 1
5.)(15 points) Create a Python program that defines a function named count_1s. This function takes an arbitrarily long list of integers as a parameter. The function should look at each list element to determine if the value is 1. The function should return the total number of times the integer 1 occurs in the list.
The program should call the function with the following list as the argument.
my_list =[1,2,3,4,5,2,3,5,1]
Print the resulting count that is returned from the program.
def (ourt.Is
rhy list (dint

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!