Views
3 years ago

Midterm No. 1 for V22.0002.005 Wednesday, October 6, 2010

Midterm No. 1 for V22.0002.005 Wednesday, October 6, 2010

Line Code1. def

Line Code1. def minus(total,decrement)2 output = total - decrement3. return(output)Line Correction of Error1. need to add colon (:) at end of line2.3.Question 11: This function solicits user input, by querying about some of the user’s personal attributes. It then printsout these attributes in a single sentence. Find 3 errors.Line Code1. def describe intelligent life form():2. height = input(’What is your height in centimeters? ’)3. species = input(’What is your species? ’)4. input(’Are you male or female?’)5. name = input(’What is your name? ’)6. favorite-food = input(’What is your favorite food? ’)7. print(’I see that you are a’, height, ’centimeters tall’, gender \8. ’specimen of the’ species, ’species’)9. print(’and that your favorite food is’, favorite-food+’.’)10. ## Example with user input: 182, male, Adam, chocolate11. ## I see that you are a 182 centimeters tall male specimen of the human species12. ## and your favorite food is chocolate.Line Correction of Error1.2.3.4. no variable is defined5.6. The variable favorite-food contains an illegal character: ’-’7.8.gender is not defined and comma required after gender9. The illegal variable favorite-food is here10.11.12.

Question 12: The length of a person’s foot is claimed to be 15% of their height. This function tests this hypothesisfor one individual. It prints out an informative statement and returns the user’s foot to height ratio. Find 4 errorsLine Code1. def test foot to height ratio():2. print(’This function calculates and records your foot-length to total height ratio.’)3. print(’All measurements should be given in inches if you are Americanor in millimeters if you are from anywhere else in the world.’)4. foot-length=float(input(’Please measure your foot and state its length: ’))5. height=input(float(’Please indicate your total height: ’))6. ratio = foot-length / height7. print(’Thank you for your participation in our study!!!!’)8. print(’Your foot-length to height ratio is: ’, ratio)9. print(’The average foot-length to height ratio may be about .15’)10. print(’Your ratio is ’, (ratio / .15) ’times that ratio’)11. return(ratio)12. ## Example print statements given user input of 11 and 72:13. ## Thank you for your participation in our study!!!!14. ## Your foot-length to height ratio is: 0.152777777777777815. ## The average foot-length to height ratio may be about .1516. ## Your ratio is 1.0185185185185186 times that ratioLine Correction of Error1.2.3. Use Triple Quotes or put a \ before the newline4. foot-length has a -, an illegal character5. input function should contain a string, not a float6. foot-length is an illegal variable7.8.9.10. add comma after second argument of print (ration / .15)11.12.13.14.15.16.

Wednesday, October 6, 2010 Finishing up from last time – climate ...
Transitioning into Practice Wednesday, October 27, 2010 Camille ...
day two: wednesday 20 october 2010 - Gitex
Wednesday, October 20, 2010 - K&L Gates
October 6-9, 2010 - Colloquium
October 6-9, 2010 - Colloquium
October 6, 2010 - Rivanna River Basin Commission
no:6 october 2010 - Galerie Jocelyn Wolff
No. 1, October 2010 - Perforacije Festival
1 Northlander October 2010 - North Country Region
Vol 6 No 2 October 2010 to March 2011 - Ghana Institution of ...
'W"ESTERN AUSTRALIA. No. 1.J WEDNESDAY, JANUARY 6. [1892.
Issue 6 – October 2010 - NECIC
October 2010 Newsletter - Tripoli Central California
28 September – 1 October 2010 Pacific Bay Resort Coffs ... - phemc
October 1, 2010 to March 31, 2011 - Peace Corps
5 reasons to be in copenhagen on 6, 7, 8 october 2010! - Post-Expo
Vol. 1, No. 3 (October - December, 2010) - Sustainable ...
New Product Bulletin - Issue 1, October 2010, 21907 - Clipsal
October 1, 2010 - Catholic High School
takeCHARGE Newsletter October 1, 2010 - TakeChargeNL
1 October 2010 - Inside American Football
5th Mini - Herpesvirus Workshop Friday, 1 October 2010, Berlin - GfV
Blue i October 2010 STU_Layout 1 - Blue Print
October 1, 2009 to March 31, 2010 - Peace Corps
October 1 - 3, 2010 - KEEP-ON-RUNNING-ST. WENDEL
Day 1 - 18 October 2010 - Asia Insurance Review