Section I | Part I
Getting started with Python
BBT 4211 - BCOM – Kurui Daniel
Section I | Part I
Why do people use Python?
• Software Quality:
• Python is designed to be readable, and hence
maintainable.
• Developer productivity:
• Python code is typically 1/3 to 1/5 the size of
equivalent C++ or JAVA code
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
What can I do with Python?
• System Programming
• GUIs
• Internet Scripting
• Database Programming
• Games, Images, AI, XML and more
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
What are Python’s Technical Strength
• It’s OO (Object Oriented)
• It’s free
• It’s Portable
• It’s Powerful
• It’s Easy to use
• It’s Easy to learn
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
What is the Downside of Python?
• Perhaps the only downside to Python is that the
execution speed may not always as fast as compiled
languages such as C and C++
• Python is not compiled all the way down to binary
machine code, it compiled to byte code instead.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Who Uses Python Today?
• Google and Yahoo currently use Python in Internet
service
• IBM use Python for hardware testing
• Industrial Light and Magic use Python in the
production of movie animation
• For more details, visit www.python.org
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
How easy is python?
• Hello World Program Implementation using three
different languages
• In C ++
• In JAVA
• In Python
• (We’ll try this practically)
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
IDE for python
• IDE stands for Integrated Development Environment. It's
a coding tool which allows you to write, test, and debug
your code in an easier way, as they typically offer code
completion or code insight by highlighting, resource
management and debugging tool.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
IDE for python cont’d
• There are quite a number of IDEs, it is difficult to choose
the best. Its upon the developers to choose which to use.
• Example of IDEs python developers can use
• Spyder
• Pycharm
• Thonny
• Atom
• Jupyter Notebook
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Text Editors
• There are quite a number of editors you can use to write
python programs
• Text Editors like Notepad. When your code is ready, you’ll
need to run it. You can’t execute your program in a text editor
like this, so you must use a prompt command to do it.
• Rather than use two different programs, wouldn’t better have
it all in just one place? That’s what an IDE is ready for.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Text Editors cont’d
• Here are some of the text editors you can use to write
python code
• Notepad
• Notepad ++
• Sublime Text
• Brackets
• Emacs
• Vim (and many more)
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Our IDE of choice
• Jupyter Notebook
• Jupyter Notebook provides an easy-to-use, interactive
data science environment across many programming
languages that doesn’t only work as an IDE, but also as a
presentation or education tool. It’s perfect for those who
are just starting out with data science!
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Jupyter Notebook
• With Jupyter, you can easily see and edit your code in
order to create compelling presentations.
• For instance, you can use data visualization libraries
like Matplotlib and Seaborn and show your graphs in
the same document where your code is.
• Besides all of this, you can export your final work to
PDF and HTML files, or you can just export it as a .py
file.
• In addition, you can also create blogs and
presentations from your notebooks.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Jupyter Notebook Cont’d
• For us to run python code using Jupyter notebook, we
must install python as well.
• Work around: Installing Anaconda or Miniconda
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Jupyter Notebook Cont’d
• Anaconda is a free and open-source distribution of the
Python and R programming languages for scientific
computing, that aims to simplify package management
and deployment
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Jupyter Notebook Cont’d
• Installation:
• Download the installer using the link:
• https://www.anaconda.com/distribution/
• Choose the package with respect to your OS
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Familiarizing with Python
print ("Hello, World! ")
Hello, World!
10 + 25
35
124 – 125
-1
1/3
0.333333333333333
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Familiarizing with Python cont’d
• Python command print – Displays data, values, and
expressions
• Python command input – Enables the user to give input
to the program.
• The single and double quotation mark string objects,
which are collections of texts surrounded by quotes.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Sample Python code
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Sample Python code cont’d
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Sample Python code cont’d
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Class Exercise
• Write a python program to print out the following:
Hello Daniel, Good morning?
How is Kenya?
Enjoy coding in python
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
Class Exercise
• Write a python program to print out the following:
Hello Daniel, Good morning?
How is Kenya?
Enjoy coding in python
• The highlighted segments should come from the
user using variables: time of the day, country and
language.
BBT 4211 - Comp Programming. Kurui Daniel
Section I | Part I
END
Any Questions?
Thank you!
BBT 4211 - Comp Programming. Kurui Daniel