1. Write a pyrhon program that prints out a classic hangman stick figure. The program should ask the user to enter a number from 1-6 and the corresponding hangman should be printed. The value the user inputs corresponds to the number of incorrect guesses in a real hangman game and so the completeness of the hangman will correspond to the number of ‘incorrect guesses’ inputted by the user (e.g., if the user enters 1, then only the head of the hangman will be printed; full example below). Example: Enter a number from 1-6: 1 O Enter a number from 1-6: 2 O | Enter a number from 1-6: 3 O \| | Enter a number from 1-6: 4 O \|/ | Enter a number from 1-6: 5 O \|/ | / Enter a number from 1-6: 6 O \|/ | / \

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Write a pyrhon program that prints out a classic hangman stick figure. The program should ask the user to enter a number from 1-6 and the corresponding hangman should be printed. The value the user inputs corresponds to the number of incorrect guesses in a real hangman game and so the completeness of the hangman will correspond to the number of ‘incorrect guesses’ inputted by the user (e.g., if the user enters 1, then only the head of the hangman will be printed; full example below).

Example:
Enter a number from 1-6: 1
O

Enter a number from 1-6: 2
O
|
Enter a number from 1-6: 3
O
\|
|
Enter a number from 1-6: 4
O
\|/
|
Enter a number from 1-6: 5
O
\|/
|
/
Enter a number from 1-6: 6
O
\|/
|
/ \

2. Modify your program from problem 1 so that the user input is checked to be a valid
single digit (1-6) before printing the corresponding hangman. If the input is not valid, then
instead of a hangman the following message should be printed “Invalid input: you must enter a
single number from 1-6.”

Example:
Enter a number from 1-6: 7
Invalid Input: you must enter a number from 1-6

Challenge: Instead of returning a generic error / invalid input message, try adding some
specificity. i.e., if the inputted string is not a number, then the returned message should specify
that the problem is that it is not a digit; if the inputted string is too long, then the returned
message should specify that the problem is that it is too long / not a single character.

Expert Solution
Step 1

Answer :

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education