When I started learning Python, I initially thought programming was mostly about memorizing different commands and writing code that works. As I started practicing, I realized that it is more about understanding how information is stored, changed and used by a program.
In this session, I focused on the basics of Python. The main areas I covered were variables, data types, input and output, comments, and basic Python syntax. These may look like simple concepts, but they form the foundation for everything I will be doing with Python later.
Why Python?
One of the things that interested me about Python is how readable the code is. Compared with some programming languages, Python does not require a lot of complicated syntax to perform simple tasks.
Python is also widely used in data analysis and data science, which is one of the reasons I am interested in learning it. Since my goal is to work with data, understanding Python gives me another tool for analyzing and solving problems.
Where do I start with Python?
The first thing I needed to understand was how to write a simple Python statement.
One of the easiest examples is:
print("Hello, World!")
The print() function displays information in the output.
I can also use it to display a calculation:
print(10 + 5)
Output:
15
This helped me understand that Python can do more than simply display text. It can also perform operations and return a result.
What is a variable?
A variable is a name that I give to a piece of information so that I can use it later in my program.
For example:
name = "Raphael"
age = 28
Here, name contains "Raphael" while age contains 28.
I can then use the variables instead of repeatedly writing the actual values:
print(name)
print(age)
Output:
Raphael
28
The = sign in this case is used to assign a value to a variable.
For example:
course = "Data Science"
I understood this as Python taking the value "Data Science" and assigning it to the variable course.
What are data types?
Not all information stored in Python is the same. Python has different data types depending on the kind of value I am working with.
Some of the basic ones I learned are:
1. Integer (int)
An integer is a whole number.
age = 28
units = 19
2. Float (float)
A float is a number that contains a decimal.
price = 500.50
height = 1.74
3. String (str)
A string is text.
name = "Raphael"
course = "Python"
4. Boolean (bool)
A Boolean has only two possible values:
is_active = True
is_complete = False
I can check the type of a value using type().
age = 28
print(type(age))
The output is:
(class 'int')
Another example:
name = "Raphael"
print(type(name))
Output:
(class 'str')
This was important for me because I learned that Python needs to know what kind of data it is working with.
What is the difference between a string and a number?
This was one of the areas I had to pay attention to.
For example:
age = 28
Here, age is an integer.
But:
age = "28"
Here, age is a string because 28 is inside quotation marks.
Although both appear to contain 28, Python treats them differently.
I can confirm this using:
print(type(age))
This made me understand why data types matter when writing programs, especially when calculations are involved.
How can a Python program receive information?
Python provides the input() function for receiving information from a user.
For example:
_name = input("What is your name? ")
print(name)
If I enter:
Raphael
Python stores the response in the name variable.
I can then use it somewhere else in the program.
_name = input("What is your name? ")
print("Welcome", name)_
The important thing I learned here is that input() normally gives me a string.
Therefore, if I ask someone to enter their age:
age = input("Enter your age: ")
the value is treated as text.
If I need it as a number, I can convert it:
age = int(input("Enter your age: "))
The int() converts the input into an integer.
Putting the concepts together
After learning variables, data types, input and output, I tried combining them into a small program.
_name = input("Enter your name: ")
age = int(input("Enter your age: "))
course = input("Enter the course you are studying: ")
print("Name:", name)
print("Age:", age)
print("Course:", course)_
If I enter:
Enter your name: Raphael
Enter your age: 28
Enter the course you are studying: Data Science
The program displays:
Name: Raphael
Age: 28
Course: Data Science
This simple example helped me see how the different concepts connect.
The program receives information, stores it in variables, converts the age to an integer, and finally displays the information.
What are comments used for?
I also learned that I can add notes to my code without affecting the way the program runs.
A comment starts with #.
Store the student's name
name = "Raphael"
print(name)
Python ignores the comment when running the program.
I found comments useful because when code becomes longer, they can help me remember what a particular section is meant to do.
A small example from my learning
I can use what I have learned to create a simple personal information program:
name = "Raphael"
age = 28
course = "Data Science"
completed_excel = True
print("Name:", name)
print("Age:", age)
print("Course:", course)
print("Completed Excel:", completed_excel)
Here I am using different data types in the same program:
name → string
age → integer
course → string
completed_excel → Boolean
This was a simple exercise, but it helped me understand that a Python program can work with different types of information at the same time.
What I understood from this session
Before this session, I could look at Python code and understand some of the words, but I did not fully understand how the different pieces fitted together.
After practicing, I now understand that a basic Python program can start with information being stored in variables. Each value has a data type, and I can use functions such as input() and print() to interact with the user.
I also learned that small details matter. For example, "28" and 28 may look similar to me, but Python treats them as different types of data.
Challenges I encountered
My biggest challenge was getting comfortable with the syntax and understanding why Python sometimes treats values differently.
I also had to understand that simply writing code is not enough. I need to understand what each line is doing.
For example:
age = int(input("Enter your age: "))
At first, this can look like one complicated line. After breaking it down, I understood that:
input() asks the user for information.
The information received is initially text.
int() converts that text into an integer.
The result is stored in the age variable.
Breaking code into smaller parts made it much easier for me to understand.
Why these basics matter to me
The concepts from this session are important because they will be used throughout my Python learning.
When I start working with datasets, I will need to understand what type of information I am dealing with. For example, a customer's name will be text, an age will normally be an integer, and a price may be a float.
I therefore see Python basics as the foundation for the more advanced topics I will learn later, including conditionals, loops, functions and data structures.
Conclusion
This session gave me my starting point in Python. I learned how to create variables, identify basic data types, receive information using input(), display results using print(), and add comments to my code.
The most important lesson for me was not just learning the commands, but understanding what is happening when the code runs.
I now have a better foundation to continue with Python and gradually move from writing simple programs to using Python to solve real data-related problems.
Top comments (0)