= 4
x = 3
y = x + y
summ print(summ)
7
Juma Shafara
September 1, 2023
November 25, 2024
What is Python, What is Python used for?, Python Displaying output
This course will teach you the basics and advanced concepts of Python Programming.
What do you need before learning Python?
Although we have not taught you how to code in Python yet, you can still easily pick up what the code is doing
Before we continue, we have a humble request, to be among the first to hear about future updates of the course materials, simply enter your email below, follow us on (formally Twitter), or subscribe to our YouTube channel.
Python is a programming language.
Python is one of the most popular programming languages
Python was created by Guido van Rossum and it was first implemented in 1989
Python is used for: 1. Web Development 2. Machine Learning 3. Data Science 4. Scripting 5. And many more
Before you can run Python on your PC, you need to install it first.
To install Python in a PC, go to https://www.python.org/downloads/ then download the latest version.
After that, install it just like how you install other apps.
Make sure that you check “Add Python to PATH” for easier installation.
In order to learn Python, you need to be able to write and execute code.
Python console also known as shell allows you to execute Python code line by line
Assuming that you have already installed Python on your PC, you can access the Python console by opening the command prompt and typing python
Let’s start using the console
Type the following and hit enter
name = 'Juma Shafara'
Again, type the following and hit enter
print(name)
After that, you should see this
Juma Shafara
Python files are saved with .py
file extension
You can use any text editor (even notepad) to create Python files
Just make sure that you save them with the .py
extension, forexample hello.py
.
Copy this code and save it as hello.py
:
print('Hello World!')
To run this Python file on a PC, navigate to the folder where is is located using the command prompt.
Then type the following and hit enter
python hello.py
The console should then output:
Hello World!
To continue practicing Python smoothly, I advice using an Integrated Development Environment. This is just a software that has features built in for you to get moving with your coding practice with ease.
Examples include:Watch this video to see how to set up Visual Studio Code for Python Programming
To display an output in Python, use the print()
function.
The print()
function can be used to print two objects. Eg.
A python statement is used to write a value, compute a value, assign a value to a variable, call a functino and many more. Eg.
In the example above, we have 4 lines of code. In python, each line typically contains one statement
You can also write multiple statements in a single of code. Simply separate the statements with semicolons ;
When coding in Python, we follow a syntax. Syntax is the set of rules followed when writing programs
Write a Python program to display the following text on the screen.
DATAIDEA
Sir Apollo Kagwa Road,
Kampala,
Uganda
-------------------
www.dataidea.org
The nice introduction ends here, in the next section, we will look at variables in Python.