Embercode
✕
Flowcharts and PseudocodeQuick quiz

Validation pseudocode

6 questions. Covers Pseudocode for input validation.

Questions 1 to 5 of 6

  1. 1. The age check below is meant to reject bad input. Which statement about it is correct? ``python def read_age(): while True: text = input("Age: ") age = int(text) if text == "" or not text.isdecimal(): print("Error: type a whole number.") continue if age > 120: print("Error: age must be 120 or less.") continue return age ``
  2. 2. Which statement about this age function is correct? ``python def read_age(): text = input("Age: ") if text == "" or not text.isdecimal(): print("Error: type a whole number.") return int(text) ``
  3. 3. Why must the range check (is the age 0 to 120?) come after the conversion to a whole number?
  4. 4. In the Python age check, which keyword does the pseudocode step NEXT PASS OF THE LOOP become?
  5. 5. Type the name of the Python string method that returns True only when every character is a decimal digit. Leave out the brackets.

    Type your answer.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.