Question

Python 3.6

I JUST NEED HELP WITH PROBLEM 2 (CONTINUATION OF PROBLEM 1)!!!

Python 3.6 Problem 1 This problem provides practice using a while Irue loop 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: 1. an integer, length, that is the length of the first word and 2. 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)) Enter a 4-letter word please two nter a 4-letter word please one Enter a 4- Enter a word beginning with B please apple Enter a word beginning with B please pear Enter a word beginning with B please banana [four, banana] letter word please four

THIS IS MY WORK FOR PROBLEM 1 (I NEED HELP WITH PROBLEM 2):

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Allign the program as per the screenshot

Answer: Program2 #define a function twoWords def twoWords (n, ch): #Declare a variables W- #printing statement sinput nA+

Editable Code:

#define a function "twoWords"

def twoWords(n,ch):

#Declare a variables

s = ""

w= ""

#printing statement

s = input('\nA ' + str(n) + '-letter word please.: ')

#while loop until "s".

while ( n != len(s)):

    #printing statement

    s = input('\nA ' + str(n) + '-letter word please.: ')

#printing statement

w = input('\nA word beginning with ' + ch+ ' please.: ')

#"while" loop until reach the lower case.

while ((w[0] != ch.lower()) & (w[0] != ch.lower())):

    #printing statement

    w = input('\nA word beginning with ' + ch+ ' please.: ')

#returs the number and string

return [s,w]

#calling statement

print(twoWords(4,'B'))

Add a comment
Know the answer?
Add Answer to:
Python 3.6 I JUST NEED HELP WITH PROBLEM 2 (CONTINUATION OF PROBLEM 1)!!! THIS IS MY...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • this us python plz follow the instructions while u solving I need the code and sane...

    this us python plz follow the instructions while u solving I need the code and sane output QUESTION 1 Write a program that performs the following: 1) request a sentence (at least two words with no punctuation marks) input by the user 2) display the first word 3) display the last letter of the first word 4) display the last word 5) display the first letter of the last word input text can be any content just make sure to...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • Python The Python "<" and ">" comparison operators can be used to compare which string variable...

    Python The Python "<" and ">" comparison operators can be used to compare which string variable has a greater value based on comparing the ASCII codes of the characters in each string, one by one. To take some examples: "tets" > "test" returns True because the third letter of the first string, "t", has a greater value than the third letter of the second string, "s". "testa" > "test" returns True because—while the first four letters in both words are...

  • LOVOU AWN 1. def remove_all_from_string(word, letter): i=0 3. while i<len(word)-1: if word[i] = letter: num =...

    LOVOU AWN 1. def remove_all_from_string(word, letter): i=0 3. while i<len(word)-1: if word[i] = letter: num = word.find(letter) word - word[:num] + word[num+1:] i=0 i=i+1 return word 10 print remove_all_from_string("hello", "1") 5 points Status: Not Submitted Write a function called remove_all_from_string that takes two strings, and returns a copy of the first string with all instances of the second string removed. This time, the second string may be any length, including 0. Test your function on the strings "bananas" and "na"....

  • Need some help on this Python Problem called "unique words" the text.txt file can be any...

    Need some help on this Python Problem called "unique words" the text.txt file can be any .txt file with words in it. Write a program that opens a specified text file and then displays the number of unique words in the text file after stripping all the white spaces, comma, and the punctuation marks and list of all the unique words found in the file. The list should be sorted in alphabetical order. The program should handle the ‘file not...

  • 6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains...

    6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two...

  • please code in python 1. Write a program to request the user enter a desired number...

    please code in python 1. Write a program to request the user enter a desired number of values. Create a loop to load the desired number of user-specified values into a list. Create two lists with the same values but generated in different ways. On list will be originally initialized to have the desired length before entering the loop. The other list will begin empty and values be appended for every iteration of the loop. Output from the program should...

  • hey dear i just need help with update my code i have the hangman program i...

    hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...

  • python List1=[ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], ["f", 4], ["g", 2]]...

    python List1=[ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], ["f", 4], ["g", 2]] 1 def function(Letter,List),example, function("c",List) return 3 2 def function(word,List),example, function("a",List) return 1, function("be",List) return 4, function("bee",[b,5],[e,20]) return 45 Dictionary = ["a","bee","ad","ae"] 3 ["a","b","y","e"] return[["a",1],["ae",2],["bee",5]] 4 input a list, find largest value words can spell, return words and value dont using loop, using recursion for those code

  • Python 9.13 LAB: Warm up: Parsing strings (1) Prompt the user for a string that contains two strings separated by a comm...

    Python 9.13 LAB: Warm up: Parsing strings (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT