Tagged: strings
Everything tagged "strings", newest first.
Python Coding Exercise #16: Calculator
A beginner Python exercise on comparing strings with if statements — build a small calculator that adds, subtracts or multiplies two numbers depending on the operation the user types.
Python Coding Exercise #14: Soup or No Soup
A beginner Python exercise on if/else with strings — ask for a name, skip the order for one particular customer, and work out the total cost for everyone else without floating-point surprises.
Python Coding Exercise #07: Print a Single Line
A beginner Python exercise on the end argument of print() — how to make several print commands write their output on one line instead of one line each.
Python Coding Exercise #05: Extra Space
A beginner Python exercise on print() and whitespace — why commas in print() add extra spaces, and how f-strings give you exact control over the output.
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.
Python Coding Exercise #03: Printing Output
Two beginner Python exercises on print() — calculating the minutes in a year inside a print statement, and printing a line of code that itself contains quotation marks.
Python Coding Exercise #02: Sorting Names
A beginner Python exercise on lists, the sort() method, and for loops — fix a program so the names of the seven brothers from "Seitsemän veljestä" print in alphabetical order.
Python Coding Exercise #01: Predict the Output
A beginner-friendly Python practice exercise focused on understanding input(), strings, integers, and basic operators. In this exercise, predict the output of a short Python program before running it, then check the answer and understand why Python produces that result.