Sitemap

Python

3 min readOct 16, 2026

--

Variables, Input, Data Types and Strings in Python

A variable is a name that refers to a value stored in the computer’s memory. I create one by writing something like age = 19. The = sign here does not mean “equal” the way it does in maths. It is an assignment, which means the value on the right is stored under the name on the left. I also learned that I can change the value later, for example by writing age = 20, and the variable will now hold the new value. Variable names can contain letters, digits and underscores, but they cannot start with a digit or contain spaces, and Python treats Age and age as two different names.

Closely connected to this is the idea of literals. A literal is a fixed value written directly in the code, like 19, 3.5, “hello” or True. So in age = 19, age is the variable and 19 is the literal. I found it helpful to think of the variable as a label and the literal as the actual thing the label points to.

Get Umarua’s stories in your inbox

Join Medium for free to get updates from this writer.

Then I learned how to take values from the user using the input() function. When I write name = input(), the program waits for the user to type something and stores it in name. The important point I learned is that input() always gives back a string, even if the user types a number. So if I want to do calculations, I have to convert it, for example age = int(input()). I can also show a message inside input(), like input(“Enter your age: “), so the user knows what to type.

Next came the basic data types. I learned that every value in Python has a type, and the first four I studied are int for whole numbers like 7, float for decimal numbers like 7.5, str for text like “Python”, and bool for the two values True and False. I can check the type of any value using the type() function, and I can convert between types using int(), float() and str(). For example, int(“25") gives the number 25, and float(3) gives 3.0.

After that, I learned about operators and expressions. An expression is a combination of values, variables and operators that Python evaluates to give a result. The arithmetic operators I learned are + for addition, — for subtraction, * for multiplication, / for division, // for floor division, % for remainder, and ** for power. One thing I noticed is that / always gives a float, so 7 / 2 is 3.5, while 7 // 2 is 3 and 7 % 2 is 1. I also learned that Python follows an order of precedence, similar to BODMAS, so 2 + 3 * 4 gives 14 and not 20, and brackets can be used to change the order.

The last part of the week was about strings. A string is a sequence of characters written inside quotes, and Python allows single quotes, double quotes, and triple quotes. Having both single and double quotes is useful because I can write “It’s a nice day” without any problem, since the apostrophe sits safely inside double quotes. Triple quotes let me write a string that spreads over several lines. I also learned that + joins two strings together, which is called concatenation, and * repeats a string, so “ha” * 3 gives “hahaha”.

--

--