Tagged: input
Everything tagged "input", newest first.
Python Coding Exercise #26: Random Number Between Two Numbers
A beginner Python exercise on the random module — generate a random whole number between two numbers with randint(), and learn that both ends are included and that the numbers must be in order.
Python Coding Exercise #25: Greatest Common Divisor
A beginner Python exercise on the math module — find the greatest common divisor of two numbers with math.gcd(), and understand what a GCD is and how Euclid's method finds it.
Python Coding Exercise #24: Binary, Octal and Hexadecimal
A beginner Python exercise on number systems — convert a decimal integer to binary, octal and hexadecimal with the built-in functions bin(), oct() and hex(), and learn what the 0b, 0o and 0x prefixes mean.
Python Coding Exercise #22: Area and Circumference of a Circle
A beginner Python exercise on the math module — read a radius, calculate a circle's area and circumference using pi, and round the answers to two decimal places.
Python Coding Exercise #21: Grams to Kilograms
A beginner Python exercise on unit conversion — turn a whole number of grams into kilograms and leftover grams, then polish the output so singular and plural words and zero values read correctly.
Python Coding Exercise #11: Food Expenditure
A beginner Python exercise that combines int(), float(), arithmetic and a multi-line f-string — estimate a user's weekly and daily food expenditure from three inputs.
Python Coding Exercise #10: Fix the Code (Product)
A beginner Python debugging exercise — why a program that asks for three numbers prints 125 instead of 30, and how using separate variables fixes it.
Python Coding Exercise #09: Calculations with Input
Three short beginner Python exercises that read numbers with input() and calculate with them — seconds in a number of days, the sum and product of two numbers, and the sum and mean of four numbers.
Python Coding Exercise #08: Converting Input to Integer
Two beginner Python exercises that turn input() into an integer with int() so it can be used in a calculation — multiplying a number by five, and working out someone's age from their birth year.
Python Coding Exercise #04: User Input and f-Strings
Five beginner Python exercises that combine input() with f-strings — printing a name twice, adding exclamation marks, formatting an address, fixing an f-string program, and filling in a story.