Question

In: Computer Science

Please write in beginner level PYTHON code! Your job is to write a Python program that...

Please write in beginner level PYTHON code!

Your job is to write a Python program that asks the user to make one of two choices: destruct or construct.

- If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade.

- If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words.

- You must enforce that the users enter real words or at least not blatant non-words. So if their input contains numbers, whitespace, punctuation, etc., you should prompt them for input until correct input is provided.

- If you manage to get all that done, then implement the following: the words output by your program must be in alternating case, starting with uppercase.

  • So, for example, if you wanted to output the word “happy”, it should be displayed as “HaPpY.”

Solutions

Expert Solution

count = 0

choice = input("Would you like to destruct 'd' or construct 'c' an alternade: ")

while count == 0:
    if choice == 'd': #if user chooses destruct
        d_word = input("Enter in alternade: ")
        test = d_word.isalpha() #checks if string is alphabets
        if test == False:
            count = 0
        else:
            first_word = d_word[0::2]
            second_word = d_word[1::2]
            print("The words are",first_word,"and",second_word)
            break


    if choice == 'c': #if user selects construct
        first_c_word = input("Enter first word: ")
        second_c_word = input("Enter second word: ")

        first_test = first_c_word.isalpha() #checks if string is alphabets
        if first_test == False:
            count = 0
        second_test = second_c_word.isalpha() #checks if string is alphabets
        if second_test == False:
            count = 0
        else:
            count = 1

        if count == 1:
            index_count = 0 #count for second word
            word = ''
            for char in first_c_word:
                char
                word += char + second_c_word.upper()[index_count]
                index_count += 1
                if len(second_c_word) == index_count:
                    print("The word is",word) #print for user
                    break

Related Solutions

Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
Please write in Python code Write a program that stores the following data in a tuple:...
Please write in Python code Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to display a menu to the user, with the following 4 options: 1 – Display minimum 2 – Display maximum 3 – Display total 4 – Display average 5 – Quit Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices
Please write in Python code please Write a program that creates a dictionary containing course numbers...
Please write in Python code please Write a program that creates a dictionary containing course numbers and the room numbers of the rooms where the courses meet. The dictionary should have the following key-value pairs: Course Number (key) Room Number (value) CS101 3004 CS102 4501 CS103 6755 NT110 1244 CM241 1411 The program should also create a dictionary containing course numbers and the names of the instructors that teach each course. The dictionary should have the following key-value pairs: Course...
1. Please program the following in Python 3 code. 2. Please share your code. 3. Please...
1. Please program the following in Python 3 code. 2. Please share your code. 3. Please show all outputs. Instructions: Run Python code  List as Stack  and verify the following calculations; submit screen shots in a single file. Postfix Expression                Result 4 5 7 2 + - * = -16 3 4 + 2  * 7 / = 2 5 7 + 6 2 -  * = 48 4 2 3 5 1 - + * + = 18   List as Stack Code: """...
CODE IN PYTHON: Your task is to write a simple program that would allow a user...
CODE IN PYTHON: Your task is to write a simple program that would allow a user to compute the cost of a road trip with a car. User will enter the total distance to be traveled in miles along with the miles per gallon (MPG) information of the car he drives and the per gallon cost of gas. Using these 3 pieces of information you can compute the gas cost of the trip. User will also enter the number of...
Please provide Python code that does the following: 3) Write a program that takes a string...
Please provide Python code that does the following: 3) Write a program that takes a string as input, checks to see if it is comprised entirely of letters, and if all those letters are lower case. The output should be one of three possible messages: Your string is comprised entirely of lower case letters. Your string is comprised entirely of letters but some or all are upper case. Your string is not comprised entirely of letters. Your program may NOT:...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user to input the string “M” if the user is a man and “W” if the user is a woman. Use only the male formula to calculate calories if “M” is entered and use only the female formula to calculate calories if “W” is entered. Output the number of chocolate bars to consume as...
C++ program, I'm a beginner so please make sure keep it simple Write a program to...
C++ program, I'm a beginner so please make sure keep it simple Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and string functions to process the data. Do not use c-string functions or stringstream (or istringstream or ostringstream) class objects for your solution. Input File.txt: Cincinnati 27, Buffalo 24 Detroit 31, Cleveland 17 Kansas City 24, Oakland 7 Carolina 35, Minnesota 10 Pittsburgh 19, NY Jets...
PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided...
PYTHON BEGINNER Problem Write a program which, given a number, simulates rolling a pair of six-sided dice that number of times. The program should keep track of how many times each possible sum comes up using a list. The list's first element should contain how many times a total of 2 was rolled, the second should contain how many times a total of 3 was rolled, and so on all the way through to 12. When all rolls are complete,...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT