Startnumber 1 length parallelogram function name

• Test Prep
• 7

This preview shows page 2 - 5 out of 7 pages.

" "*( startnumber-1) + "*"*length parallelogram() Function Name: getUserInfo() Parameters: None Return Value: None Description: Write a user-interactive function that asks for a user's name . The function then prints a greeting for the user, composed of some information about the user's name. A session should look like the following: 2 | am/cpsc111-Su16-Asg1.docx Assigned: Monday, July 18 th
CPSC111-Introduction to computing By Dr. Ahmed Malki – Asg. #1 (Summer-16) What is your name? Muhammad Ali Hello Muhammad Ali! Your name starts with an M, ends with an i and is 12 Characters long. Nice meeting you! Also, write the code that will demonstrate your function. # getUserInfo() #ask for a user's name and print a greeting #and also get the first and last letter of the user's name and the length of name def getUserInfo(): yourName = raw_input ('What is your name? ') print 'Hello ' + yourName +"!" print 'Your name starts with an',yourName[0] + ', ends with an' ,yourName[len(yourName)-1] +' and is', str( len(yourName) ) +' Characters long.' print 'Nice meeting you!' getUserInfo() Function Name: conversionProcess() Study the program below. It will input a weight (in pounds) and convert the weight to kilograms. The result of the conversion will be output to the console. The formula used to convert pounds to kilograms is as follows; kilogram = pounds * 0.45359 # # Program to convert LBs to KGs # # This function will input the pounds from the user def get_pounds() : user_input = raw_input("Please enter your weight in pounds (LB) : ") pounds = float(user_input) print " You have entered ", pounds, " LB\n" return pounds 3 | am/cpsc111-Su16-Asg1.docx Assigned: Monday, July 18 th
CPSC111-Introduction to computing By Dr. Ahmed Malki – Asg. #1 (Summer-16) # This function will convert lbs into kilograms def lb_to_kg(pounds) : return (pounds * 0.45349); # main/start of the program lb = get_pounds() kg = lb_to_kg(lb) print print "Your weight converted to Kilograms, is : ", kg, " Kg" print print "Thank-you" Question : Now, write your own Python program to input kilometers and convert them to miles. You can use the following formula for this purpose. miles = 0.621371 * kilometers Note - you must use the Python program above, as a pattern for your own work. Make changes to this pattern so that it will input kilometers and convert to miles.