Phython Day1
Phython Day1
DAY 1
PYTHON BASIC 1
PYTHON PROGRAMMING ESSENTIALS
for experienced programmers with other programming languages like
Python
DAY 1 PYTHON PROGRAMMING ESSENTIALS 2
Python
DAY 1 PYTHON PROGRAMMING ESSENTIALS 3
Python Libraries
DAY 1 PYTHON PROGRAMMING ESSENTIALS 4
Python History
DAY 1 PYTHON PROGRAMMING ESSENTIALS 5
Python History
Python Applications
DAY 1 PYTHON PROGRAMMING ESSENTIALS 7Advantages
Applications
Presence of third-party modules
Extensive support libraries(NumPy for GUI based desktop applications(Games,
numerical calculations, Pandas for data Scientific Applications)
Web frameworks and applications
analytics etc)
Enterprise and Business applications
Open source and community development
Easy to learn User-friendly data assigned, it
takes data type)
structures High-level language Operating Systems Language
Dynamically typed language(No need to Development Prototyping
mention data type based on value
DAY 1
PYTHON
PROGRAMMING ESSENTIALS
Python
Interpreter
Installation
Step 1.
Download the latest
python from the
official website
https://www.python.org/downloads/
Python Interpreter
Installation
Step 2:
Run the Python
Installer from
download folder
Step 3:
Make sure to mark
Add Python 3.7 to
PATH.
Click Install Now or
Custom Installation
Installation
Step 4:
Installation Finish!
Python IDLE
DAY 1 PYTHON PROGRAMMING ESSENTIALS 13
IDLE (Integrated Development
and Learning Environment) is an
integrated development
environment (IDE) for Python.
The Python installer for
Windows contains the IDLE
module by default.
Python Editor/IDE
DAY 1 PYTHON PROGRAMMING ESSENTIALS 14
Online Editor/Interpreter
Offline Editor/IDE
http://ideone.com/ Sublime Text
https://ide.geeksforgeeks.org/
Notepad / Notepad++
http://codepad.org/
PyCharm
Visual Studio Code
2. Set the environment settings to python
Creating & Executing Python File DAY 1 PYTHON
PROGRAMMING ESSENTIALS 15
Python Identifiers
DAY 1 PYTHON PROGRAMMING ESSENTIALS 17
Keywords
DAY 1 PYTHON PROGRAMMING ESSENTIALS True
18
None
class
and or def
not If
Indentation
DAY 1 PYTHON PROGRAMMING ESSENTIALS 19
if age>18:
print(“Legal Age”)
else:
print(“Underage”)
Comment
DAY 1 PYTHON PROGRAMMING ESSENTIALS Single line comment (#)
20
#this is a comment
print(“hello world”)
Quotations
DAY 1 PYTHON PROGRAMMING ESSENTIALS 21
It accepts single (‘), double (“) and triple (‘’’ or ”””)for text or
string
txt1 = ‘hello'
txt2 = "I am a sentence."
txt2 = """I am another sentence made up of multiple lines."""
Taking input/output
DAY 1 PYTHON PROGRAMMING ESSENTIALS 22
Taking input
DAY 1 PYTHON PROGRAMMING ESSENTIALS 23
print(var)
name = input("Enter your name: ") print("Hi " + name + " your age
is " , var)
Output using print() DAY 1 PYTHON PROGRAMMING ESSENTIALS 25# Using print() function in
Python
# One object is passed
print("Red fox say")
Exercise 1
Filename: Day1_Exe1_Lastname_Firstname.py
1. F-Strings f or F
2. String modulo operator % 3. String Format method { }
Output Formatting
DAY 1 PYTHON PROGRAMMING ESSENTIALS 27 Several ways to present an
output of the program
F-Strings f or F
print(F”The quick {color} {animal}”)
Output Formatting
DAY 1 PYTHON PROGRAMMING ESSENTIALS 28
food = “rice”
pack = 2
print(f”Eat {pack} cup(s) of {food} every meal.”)
animal = input(“Enter animal: ”) color = input(“Enter color: “)
String modulo operator %
print(”1 cup of %s cost %.2f”%(food, prize))
Output Formatting
DAY 1 PYTHON PROGRAMMING ESSENTIALS 29
food = “rice”
prize = 35.6743
male = 40
female = 32
print(”Total students: %d Males: %d Females:”%(male, female))
Output Formatting
DAY 1 PYTHON PROGRAMMING ESSENTIALS 30
Output Formatting
DAY 1 PYTHON PROGRAMMING ESSENTIALS 31
String Format method { }
preAmt = 4521.35462
policy = "Insurance"
holder = "Will Smith"
#format specifier
print("Premium amount: {:.3f}".format(preAmt))
b. Sewage Charge
c. Electric Charge
d. City Tax
2. Display the result with the given format below Water Charge
118 peso(s) 25 cent(s)
Sewage Charge 20 peso(s) 8 cent(s)
Electric Charge 1250 peso(s) 76 cent(s)
City Tax 50 0 cent(s)
Exercise 2
Filename: Day1_Exe2_Lastname_Firstname.py
Summary
DAY 1 PYTHON PROGRAMMING ESSENTIALS 33
Introduction
Installation of Python Interpreter
Familiarization on Code Editor and IDE Creating
first Python program Identifiers
Basic Syntax
Taking input/output
Output Formatting