subject

Problem 1: Write a function named twoWords that gets and returns two words from a user. The first word is of a specified length, and the second word begins with a specified letter. The function twoWords takes two parameters:

i. an integer, length, that is the length of the first word and
ii. a character, firstLetter, that is the first letter of the second word. The second word may begin with either an upper or lower case instance of firstLetter. The function twoWords should return the two words in a list. Use a while True loop and a break statement in the implementation of twoWords.

The following is an example of the execution of twoWords:

print(twoWords(4, 'B')) A 4-letter word please :two
A 4-letter word please: one
A 4-letter word please : four
A word beginning with B please : apple
A word beginning with B please: pear
A word beginning with B please: banana
['four', 'banana']

Write a function named twoWordsV2 that has the same specification as Problem 1, but implement it using while and not using break. (Hint: provide a different boolean condition for while.) Since only the implementation has changed, and not the specification, for a given input the output should be identical to the output in Problem 1.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:00, sebcbal
When is a chart legend used a. all the time b. whenever you are comparing data that is the same c. whenever you are comparing multiple sets of data d. only for hand-drawn charts
Answers: 2
image
Computers and Technology, 23.06.2019 07:00, bskyeb14579
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, shadowsnake
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible. restrictions: branches or loops should not be used. the code must use the internal mod and logical functions. hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible. this is matlab
Answers: 2
image
Computers and Technology, 23.06.2019 11:30, kyraj21
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
You know the right answer?
Problem 1: Write a function named twoWords that gets and returns two words from a user. The first w...

Questions in other subjects:

Konu
Mathematics, 10.12.2020 01:00