Question: code from 17) use for solving 19): sum =0 count =10 while count sum =sum +count count = count -1 ***Please ignore question 20 19)

code from 17) use for solving 19):

sum =0

count =10

while count

sum =sum +count

count = count -1

***Please ignore question 20 code from 17) use for solving 19): sum =0 count =10 while

count sum =sum +count count = count -1 ***Please ignore question 20

19) Rewrite the code in problem 17) so that a for loop is used instead of a while loop At the end of the execution of the code the value in variable sum should be the same as it is in problem 17) 20) Rewrite your solution to Problem 8), above, so that it is a function. The name of the function is 'slope' t takes the x- and y-coordinates of the two points as parameters. It returns the slope. It does not print any information on the screen and does not interact with the person who is running the program Chapter 5, Sections 5.1, 5.4, and 5.5, pp. 185 200 and 209 230 21) Write a function that return a random number chosen from the values-1, 0, and 1 The function takes no parameters. 22) Write a function that prompts a user to enter the year that they were born and reads user input. Validate that the user entered a year between 1920 and 2010 inclusive, and re-prompt until the user enters a year that is in the correct range The function takes no parameters, and it returns the validated year of birth 23) Evaluate the following expressions: a) 24 20 and 20 34 b) not 25 % 5--Oor 14/3- 4 Chapter 6, Sections 6.1-6.3, and searching in Section 6.5, pp. 241 270 and 279 - 286. Skip the material in Section 6.2 about reading content from a web page on pp 254 - 258 24) 'sentence' is a string variable that contains the following text: Two of us went to the zoo, too Write a segment of code that will modify the contents of the variable sentence so that it contains: Three of us went to the park, also 25) Suppose you want to write a function that counts how many words are in a string. What characters should you look for to determine the boundary of a word: Digits? Whitespace? Punctuation? Something else? 26) Write the function for problem 25) above. It takes a string variable that contains the input from a user. It returns a number that represents how many words were found in the string variable. If the string is empty, it returns 0. 27) How many times is the word "Yahoo!" printed by the code below? for vall in range (1,3): for val2 in range (2,4) print ("Yahoo!")

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 Databases Questions!