Introduction to Python
What is Python? Python is like the way you give a computer instructions.
Why is Python preferred for beginners
- It's easy to learn and understand
- It's one of the most in-demand skills in the market today
- It's free and open-source
- It's used to automate tasks, build websites, and analyze data
Core concepts & Basic Python Functions
print()
This is basically like giving a computer some instructions on what it should print on the screen.
variables
Variables are used to store information for reference, hence acting as a memory for your computer.
Python Variable Writing Rules
- Can contain letters, digits, and underscores
- Cannot contain spaces or special characters (
%,-,!,@) - Is case-sensitive (
ageandAgeare different) - Cannot be a reserved Python keyword
Data Types
Python treats different types of data differently.
You can add two numbers, and you can join two texts.
Note: You cannot add a number and text together.
There are 4 main types of data:
String (str): Used to represent text/characters. You can also use str() to convert other values to text.
name = 'Amina Wanjiku'
city = 'Nairobi'
print(type(name), type(city))
Integer (int): Represents whole numbers without decimals.
age = 30
score = 95
print(type(age))
Float (float): Represents real numbers containing a decimal point or fractional part.
height = 1.75
balance = 100.50
print(type(height))
Boolean(bool): Represents truth values—either True ** or **False
is_student = True
has_id_card = False
print(type(is_student))
The input() function
This type of function in Python pauses execution to read a line of text entered by the user from the keyboard.
name = input('Enter your name: ')
print()
print('Hello', name)
print('Welcome to the Python programming course!')
f-string() function
Conclusion
You now know how to take user input, store it in variables, and print results back to the screen!
To test your skills, try to write a short script asking the user for their name and age using the input() function, convert the age into an integer, and print how old they will be in 5 years. Drop your code in the comments below.
Cheers and Happy learning!



Top comments (0)