Define a function called input_name () that has no parameters and returns the user's input name....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Define a function called input_name () that has no parameters and returns the user's input name. It should prompt for and take keyboard input for the player's name. It should validate this input in a loop to ensure the name contains no space characters and that the length of the name is less than 12. An error message should be displayed whenever the user enters an invalid name. In the play_game () function, if the user wants to play, call the input_name () function to take input for their name. Store the returned value in a variable. Run the code to ensure the validation loop is working: Define a function called input_name () that has no parameters and returns the user's input name. It should prompt for and take keyboard input for the player's name. It should validate this input in a loop to ensure the name contains no space characters and that the length of the name is less than 12. An error message should be displayed whenever the user enters an invalid name. In the play_game () function, if the user wants to play, call the input_name () function to take input for their name. Store the returned value in a variable. Run the code to ensure the validation loop is working:
Expert Answer:
Answer rating: 100% (QA)
def inputname while True username inputEnter your name no spaces max 12 characters if in use... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Evaluate the importance of an internal environmental analysis for a healthcare organization. Determine three specific reasons why an internal analysis has become an important activity for healthcare...
-
Trish at Bargain Used Books continues to use the programs you developed for her. You expect that at some point, Trish will ask you to extend the types of items that she currently sells. So you've...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Lucy, a 57-year-old widow, lost her husband in 2021. He was an active participant in the Federal Employees' Retirement System (FERS), and his FERS contributions totaled $27,000 at the time of his...
-
Predict the structure of the product formed in the reaction of the organic base pyridine with the organic acid acetic acid, and use curved arrows to indicate the direction of electronflow. Pyridine...
-
Show that P2 is panned by {1 + 2x2, 3x, 1 + x}.
-
Electron 1 , initially traveling to the right at \(1.5 \times 10^{6} \mathrm{~m} / \mathrm{s}\), is accelerated upward at \(900 \mathrm{~m} / \mathrm{s}^{2}\) by the electromagnetic force exerted by...
-
Adamantane Inc. processes a base chemical into plastic. Standard costs and actual costs for direct materials, direct labor, and factory overhead incurred for the manufactureof 15,000 units of product...
-
Explain why clients may want to have a review, versus an audit. In detail, explain the differences between a certified audit and a review. In addition, what role does an internal auditor play in...
-
Hector Fuego had just been hired by the board of directors to become the new CEO of You Build, Inc. You Build is a 50-year-old building supply company that operates in the southwestern United States....
-
An option strategy called the iron butterfly is illustrated in the payoff diagram below. Payoff 40 Iron butterfly Type X T-t Put 45 1 Call 45 1 Put 50 1 Call 50 1 Put 55 1 Call 55 1 Premium $1.876...
-
Rewrite Exercise 5, making MergeLists a linked member function of the Sorted List ADT. Exercise 5 Rewrite Exercise 4, making MergeLists an array-based member function of the Sorted List ADT. Exercise...
-
A merge sort is used to sort an array of 1,000 test scores in descending order. Which of the following statements is true? 1. The sort is fastest if the original test scores are sorted from smallest...
-
How do we tell if a Find operation on a map was successful?
-
Give arguments for and against using functions (such as Swap) to encapsulate frequently used code in a sorting routine.
-
A priority queue is implemented as a heap: 1. Show how the heap would look after this series of operations: 2. What would the values of x, y, and z be after the series of operations in part (a)? 25...
-
You dissolve a known mass of solute in a known mass of water and read the total volume. The molar mass of the solute can be determined by measuring which other quantity? the density of the solution...
-
Reduction in sales All of the above 29. Belt of an electric motor is broken, it needs a. Corrective maintenance b. Scheduled maintenance c. Preventive maintenance d. Timely maintenance. 30. The...
-
Derive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that...
-
Repeat Programming Project 5 but in addition ask the user if he or she is a. Sedentary b. Somewhat active (exercise occasionally) c. Active (exercise 34 days per week) d. Highly active (exercise...
-
Suppose that we are selling boxes of candy for a fund-raiser. We have five kinds of candy to sell: Mints, Chocolates with Nuts, Chewy Chocolates, Dark Chocolate Creams, and Sugar-Free Suckers. We...
-
Figure \(\mathrm{P} 10. 16\) represents two stroboscopic pictures (taken at the same flash rate) of a block moving along a ramp that exerts a frictional force on the block. In one sketch, the block...
-
You keep a chalkboard eraser pressed against the chalkboard by using your finger to exert a horizontal force on the back of the eraser. (a) Which type of force (call it force A) keeps the eraser from...
-
In Figure P10.18, all surfaces experience friction. Is the magnitude of the horizontal component of the force exerted by \(A\) on \(B\) greater than, equal to, or less than the magnitude of the...
Study smarter with the SolutionInn App