Ch5 Python Programming Basics
Ch5 Python Programming Basics
Python
Programming
Basics
CS158 - 1 Artificial Intelligence
School of Information Technology
Raymond B. Sedilla, MSIT
Python is one of the achievements
of free software and is purely free
software and both its source code
and interpreter comply with the
GNU General Public License (GPL)
protocol.
https://www.w3schools.com/python/python_intro.asp
Works on different platforms
(Windows, Mac, Linux, Raspberry
Pi, etc).
It runs on an interpreter
system.
https://www.w3schools.com/python/python_intro.asp
Facts about Python
1. Python is currently the most widely used multi-purpose, high-level
programming language.
2. Python allows programming in Object-Oriented and Procedural
paradigms.
3. Python programs generally are smaller than other programming
languages like Java. Programmers have to type relatively less and the
indentation requirement of the language makes them readable all the
time.
4. Python language is being used by almost all tech-giant companies like
– Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
Facts about Python
5. The biggest strength of Python is its huge collection of standard
libraries which can be used for the following:
Machine Learning
GUI Applications (like Kivy, Tkinter, PyQt, etc. )
Web frameworks like Django (used by YouTube, Instagram, Dropbox)
Image processing (like OpenCV, Pillow)
Web scraping (like Scrapy, BeautifulSoup, Selenium)
Test frameworks
Multimedia
Scientific computing
Text processing and many more..
Advantages :
Presence of third-party modules
Extensive support libraries(NumPy for numerical calculations, Pandas
for data analytics, etc)
Open source and community development
Versatile, Easy to read, learn and write
User-friendly data structures
High-level language
Dynamically typed language(No need to mention data type based on
the value assigned, it takes data type)
Object-oriented language
Portable and Interactive
Ideal for prototypes – provide more functionality with less coding
Advantages..
Highly Efficient(Python’s clean object-oriented design provides
enhanced process control, and the language is equipped with
excellent text processing and integration capabilities, as well as
its own unit testing framework, which makes it more efficient.)
(IoT)Internet of Things Opportunities
Interpreted Language
Portable across Operating systems
Applications :
GUI based desktop applications
Graphic design, image processing applications, Games, and
Scientific/ computational Applications
Web frameworks and applications
Enterprise and Business applications
Operating Systems
Education
Database Access
Language Development
Prototyping
Software Development
Organizations using Python
Python Keywords
Keywords in Python are reserved words that can not be used as a variable
name, function name, or any other identifier.
https://www.w3schools.com/python/python_intro.asp
Python Numbers
https://www.w3schools.com/python/python_intro.asp
Python Strings
'hello' is the same as "hello".
https://www.w3schools.com/python/python_intro.asp
Python Booleans
In programming, you often need to know if an expression is True or
False.
You can evaluate any expression in Python, and get one of two
answers, True or False.
When you compare two values, the expression is evaluated and Python
returns the Boolean answer:
https://www.w3schools.com/python/python_intro.asp
Python Operators
Python divides the operators in the following groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators
https://www.w3schools.com/python/python_intro.asp
Python Lists
Lists are used to store multiple items in a single variable.
https://www.w3schools.com/python/python_intro.asp
Python Tuple
Tuples are used to store multiple items in a single variable.
https://www.w3schools.com/python/python_intro.asp
Python Sets
Sets are used to store multiple items in a single variable.
https://www.w3schools.com/python/python_intro.asp
Python Dictionaries
Dictionaries are used to store data values in key:value pairs.
Dictionaries are written with curly brackets, and have keys and values:
https://www.w3schools.com/python/python_intro.asp
Python If ... Else
Python supports the usual logical conditions from mathematics:
Equals: a == b
Not Equals: a != b
Less than: a < b
Less than or equal to: a <= b
Greater than: a > b
Greater than or equal to: a >= b
https://www.w3schools.com/python/python_intro.asp
Python Loops
Python has two primitive loop commands:
https://www.w3schools.com/python/python_intro.asp