Tagged: input
Everything tagged "input", newest first.
Python Coding Exercise #54: String Multiplied
A beginner Python exercise on string repetition — ask for a string and an amount, then print the string that many times on one line using the * operator.
Python Coding Exercise #46: Repeat Password
A beginner Python exercise on loops and input — ask for a password once, then keep asking the user to repeat it until it matches, and learn which lines belong inside the loop and which outside.
Python Coding Exercise #43: Shall We Continue?
A beginner Python exercise on your first while loop — repeat a message until the user types "no", and learn how while True and break work together.
Python Coding Exercise #36: Age Check
A beginner Python exercise on if, elif and else with three outcomes — respond to an age that is normal, too young, or impossible — and learn why the order of the conditions matters.
Python Coding Exercise #34: The Elder
A beginner Python exercise on if, elif and else — read the names and ages of two people, print the name of the elder, and avoid the mistakes of comparing the wrong variables or comparing ages as text.
Python Coding Exercise #33: Greater Than or Equal To
A beginner Python exercise on if, elif and else — compare two numbers, print the greater one, and handle the case where they are equal.
Python Coding Exercise #32: Age of Maturity
A beginner Python exercise on if and else — decide whether someone is of age using 18 as the limit, and see why the boundary value 18 is the number to test.
Python Coding Exercise #31: Typecasting
A beginner Python exercise on type conversion — use int() to split a decimal number into its integer part and decimal part, and see why the decimal part can print with extra digits.
Python Coding Exercise #28: Solving a Quadratic Equation
A beginner Python exercise that turns the quadratic formula into code — read a, b and c, calculate the discriminant, and use sqrt() to find the two roots, with attention to brackets and order of operations.
Python Coding Exercise #27: Hypotenuse of a Right-Angled Triangle
A beginner Python exercise on the math module — use Pythagoras' theorem and sqrt() to find the hypotenuse of a right-angled triangle, read decimal sides with float(), and format the answer to two decimal places.