Search for question
Question

Introduction to Programming - Spring 2024 CIT129 Assignment #12 ● DO NOT post the text of this assignment on any web sites. • DO NOT share your answers with anyone. • DO NOT collaborate on completing work with anyone. • DO NOT use the Internet to search for solution to assignments. ● DO NOT pay anyone to write your code. • Avoid web sites that offer solutions to assignments. These include AI tools such as ChatGPT, chegg.com, CourseHero, etc. If you copy work from such web sites, keep in mind that other students are also looking at the same information and will therefore submit duplicated work. Failure to meet these requirements leads to the violation of the academic integrity principles as stated in your syllabus. Objective: Demonstrate your understanding of solving problems that involve using functions in programs. This assignment is based on the material covered in PE Module 4 – Functions - Sections 4.1 and 4.2 of your Net Academy and the material offered in Canvas. What to submit: Submit your Python source file. Use the file format: FirstNameLastNameCIT129_hw12.py for your file name. Submit your file to the assignment dropbox in Canvas. Documentation: I am also asking for code documentation. You should already know about this requirement. Constraints: • All functions are run through the main function • Define your functions first and then call functions as required • Feel free to use any pre-defined functions • Do not use any global variables • • Do not use exit, break, or continue in loops or functions Format any decimal numbers to 2 digits after the decimal point, unless otherwise noted. Assignment: Write Python programs that exercise your understanding of defining and using functions in Python. You should build your code one function at a time, test it, and move to the next part. Process and additional criteria: CIT129 - Assignment 12 - Python Functions (Basics) a) Write a function to display your own full name, this course number (e.g. CIT129), and the number of hours it took you to complete this assignment. Note there is no input statements inside this function. We are NOT asking the user for input. b) Write a function that accepts the weight of a person in pounds as its parameter and displays the weight in kilograms. The simple conversion formula is: kilogram = pounds / 2.2 c) Write a function that accepts as its parameters, the weight, height in feet, and height in inches and display the Body Mass Index (BMI). BMI is calculated as: BMI = weight in pounds * 703 / (height in inches²) d) Write a function that accepts as its parameter 3 whole numbers representing the starting value, the end value, and the step size of a set of numbers to display. The function displays all whole numbers between the first and second number with an increment of the third number. If the first number is more than the second number, print an error message. e) Write the main function to call these functions and perform the required tasks. In the main function: • Call your function to display the information. • • • Ask the user for weight in pounds. Validate the number to make sure it is more than 0 (need a loop to validate). Call your function and show the converted value. Ask the user for height in feet and height in inches, call your function, and display the value of BMI. Ask the user for 3 numbers and call your function to display the data. Here is the skeleton of a sample code that you may want to follow: # display information def info(): # convert weight in pounds to kilograms def convertWeight(weightPound): #calculate Body Mass Index def findBMI(weight, heightFeet, heightInches): # display data def displaydata (first, second, increment): #the main function def main(): # call the functions to process the data CIT129 - Assignment 12 – Python Functions (Basics) - main() ### call the main to start the process Sample test run 1- Make sure to fully test your code. Make sure to re-create all the output shown in the sample runs. Sample Test run 1: - make sure to fully test your code. Donald Duck CIT129 Number of hours to complete this assignment: 2 hours Enter weight in pounds: -2 Invalid weight - Enter weight in pounds: 0 Invalid weight - Enter weight in pounds: 160 Weight in Kilograms 72.73 Enter your height in feet: 5 Enter your height in inches: 8 BMI: 24.33 Enter starting value of a set of numbers to print: -10 Enter ending value of a set of numbers to print: 10 Enter the increment for the set of numbers to print: 5 -10 -5 0 5 10 Sample test run 2: Donald Duck CIT129 Number of hours to complete this assignment: 2 hours Enter weight in pounds: 120 Weight in Kilograms = 54.55 Enter your height in feet: 5 Enter your height in inches: 3 BMI: 21.25 Enter starting value of a set of numbers to print: 10 Enter ending value of a set of numbers to print: 1 Enter the increment for the set of numbers to print: 1 There is no data to display! CIT129 - Assignment 12 - Python Functions (Basics)