Question

In this module you learned about making decisions. You learned about the syntax and rules used...

In this module you learned about making decisions. You learned about the syntax and rules used to develop programs containing decisions and how the logic can make your programs more robust. Draw a flowchart for a program that shows the logic for a program that generates a random number. The program will simulate tossing coin. The program should generate a random number(0 and 1). If the random number is 0, then it should display the word "Heads". If the random number is 1, then it should display the word "Tails". You want to add the code so the player can enter their name, then display a welcome message using their name. You also want to display a message that describes what the program will do. When your program ends, thank the person for playing. There are NO LOOPS, NO Functions or NO MODULES at this point. Everything at this point is in sequence(Line-By-Line). You can add comments at the beginning of each block to explain what the code is doing.. Make a working version of this program in Python. Complete the flowchart. Upload it to the Blackboard assignment area by clicking on the Browse My Computer button below the text editor. Complete the Python code using IDLE. Upload your .py file to the Blackboard assignment area by clicking on the Browse My Computer button below the text editor.

Homework Answers

Answer #1

import random
#prompt the user to enter a name
name = input("Enter your name:\t")
#display the welcome message for the user
print("Hello " + name + ", Welcome to Coin Tossing Game")
#describe the game
print("Here you have to toss a coin and it will show the result")
#prompt the user whether they want to toss the coin
ch = input("want to toss a coin?(y/n) ")
#if the user enter y
if(ch == "y"):
   #generate a random number between 0 and 1
   coin = random.randint(0, 1)
   #check the number is 0 or 1 and print the message
   if(coin == 1):
       print("Heads")
   else:
       print("Tails")
#display the ending message
print("Thank you for playing the game")

Follow the image for indentation

If you have any doubts please comment and please don't dislike.

Know the answer?
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
Similar Questions
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
You must use Windows Programming(Do NOT use Console) to complete this assignment. Use any C# method...
You must use Windows Programming(Do NOT use Console) to complete this assignment. Use any C# method you already know. Create a Windows application that function like a banking account register. Separate the business logic from the presentation layer. The graphical user interface should allow user to input the account name, number, and balance. Provide TextBox objects for withdrawals and deposits. A button object should be available for clicking to process withdrawal and deposit transactions showing the new balance. Document and...
Code a program to reproduce Madame Esmerelda’s clairvoyant test: Mme. Esmerelda conjures up a random number...
Code a program to reproduce Madame Esmerelda’s clairvoyant test: Mme. Esmerelda conjures up a random number 1-10 in her mind and commands the user to guess what it is. If the user’s guess is equal to (remember your double equal sign!) the conjured number, Mme. Esmerelda extends a job offer as a clairvoyant assistant. Add a user-driven loop that allows the user to play repeatedly if desired (but your program should conjure a new random number with every loop iteration)....
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the...
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the number of interior and exterior murals scheduled to be painted during the next month. The program computes the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. In this assignment, you are going to design a GUI version using Visual Studio Form. The programs prompt a user for the number of interior and exterior...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS OR SWITCH STATEMENTS IN THE JAVASCRIPT. Even though there is stylesheet in the HTML file do no create a new one. Project Standards: Students will use click events to capture user input. Students will use variables to store information needed by their application and keep track of their program’s state. Students will use conditionals to control project flow. Project Task You will be building...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.) void search_node(struct linked_list* list, int find_node_ value) (The function to make) This function finds the node from the list that value is same with find_node_value and count the order of the node. This function should print message “The order of (node_value) is (order).” and error message “Function search_node : There is no such node to search.”....
For this project, you will make decisions about how two parameters (proportions or means) compare using...
For this project, you will make decisions about how two parameters (proportions or means) compare using hypothesis tests, and you will estimate the difference between the two parameters using confidence intervals. For each confidence, report the following: the confidence interval limits rounded as directed (from StatCrunch) An interpretation of the confidence interval (e.g. "I am 95% confident ... .") Here is a template for reporting the answer for a sample confidence interval problem. Sample problem: Find a 90% confidence interval...
comment on 2 things you learned from this chapter of the Cognitive development ece 124 chapter...
comment on 2 things you learned from this chapter of the Cognitive development ece 124 chapter 9 Piaget -Preoperational intelligence • Cognitive development between the ages of about 2 and 6 • Includes language and imagination • Suggests logical, operational thinking is not yet possible at this stage Piaget: Symbolic Thought • Major accomplishment of preoperational intelligence • Allows a child to think symbolically, including understanding that words can refer to things not seen and that an item can symbolize...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version I accept the point that whenever learning occurs, some medium or mix of media must be present to deliver instruction. However, if learning occurs as a result of exposure to any media, the learning is caused by the instructional method embedded in the media presentation....