0% found this document useful (0 votes)
2 views27 pages

Week 1P - Introduction to Python Programming

This document provides an introduction to Python programming, highlighting its features, advantages, and applications such as data analysis and web development. It covers best programming practices, data types, and keywords, along with guidance on using Anaconda for Python installation. Additionally, it includes practical exercises and a class project for hands-on learning.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
2 views27 pages

Week 1P - Introduction to Python Programming

This document provides an introduction to Python programming, highlighting its features, advantages, and applications such as data analysis and web development. It covers best programming practices, data types, and keywords, along with guidance on using Anaconda for Python installation. Additionally, it includes practical exercises and a class project for hands-on learning.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 27

Introduction to Python Programming

Practice
Why Python Programming?
2

Python is a very popular


general-purpose
It is a dynamically-typed It was created by Guido
interpreted, interactive,
and garbage-collected van Rossum during 1985-
object-oriented, and high-
programming language. 1990.
level programming
language.

Python supports multiple


programming paradigms, Python design philosophy
including Procedural, emphasizes code
Object Oriented and readability with the use of
Functional programming significant indentation.
language.
Features of Python programming language
3

Readable

Memory Easy to learn


Management

Features
of
Large Standard Python Free
Library

Exception
Open Source
Handling
What Can You Do with Python?
4

Scripting Game
Development
Data
Analysis
Machine
Learning
Web
Development
Python IDEs and Code Editors
5

Jupyter
IDLE
Notebook

Spyder Atom

Visual Studio
Sublime Text
Code

Eclipse
PyCharm
Advantages of learning Python
6

Python is Interpreted
• Python is processed at runtime by the interpreter. You do not need
to compile your program before executing it. This is similar to PERL
and PHP.
Python is Interactive
• You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
Python is Object-Oriented
• Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
Python is a Beginner's Language
• Python is a great language for the beginner-level programmers and
supports the development of a wide range of applications from
simple text processing to WWW browsers to games.
Some companies Using Python
7

Google Intel NASA

PayPal Facebook IBM

Amazon Netflix Pinterest

Uber
ANACONDA (Python distribution)
8

Anaconda is a distribution of
the Python and R programming Anaconda Navigator is a
languages for scientific desktop graphical user interface
computing (data (GUI) included in Anaconda
science, machine distribution that allows users to
learning applications, large-scale launch applications and manage
data processing, predictive conda packages, environments
analytics, etc.), that aims to and channels without
simplify package using command-line commands.
management and deployment.
Installing on Windows
9

Download Anaconda >>


https://docs.anaconda.com/anaconda/install/windows/
Installing on MacOS
10

Download Anaconda >>

https://docs.anaconda.com/anaconda/install/mac-os/
ANACONDA IDE
11
Jupyter Notebook
12
Best Programming Practices
13

Commenting & documentation


Best Programming Practices
14

Consistent Indentation
Best Programming Practices
15

Avoid Deep Nesting


Best Programming Practices
16

Follow the DRY Principle


• DRY stands for “Don’t Repeat Yourself.
• The same piece of code should not be repeated over and
over again.

File and Folder Organization


• You should avoid writing all of your code in one of 1-2 files.
• It break your app but it would be a nightmare to read,
debug and maintain your application later.
• Keeping a clean folder structure will make the code a lot
more readable and maintainable.
Python Variables with examples
17

Variable name is known as identifier. There are few rules that


you have to follow while naming the variables in Python.
• The name of the variable must always start with either a letter or an
underscore (_). For example: _str, str, num, _num are all valid name for
the variables.

• The name of the variable cannot start with a number. For example: 9num
is not a valid variable name.

• The name of the variable cannot have special characters such as %, $, #


etc, they can only have alphanumeric characters and underscore (A to Z, a
to z, 0-9 or _ ).

• Variable name is case sensitive in Python which means num and NUM are
two different variables in python.
Python String Variable
18

Enter the code in the cell block and press the Shift + Enter key
Python Data Types
19

A data type defines the type of data, for example:


123 is an integer data,
“hello” is a string data type,
2.33 is a float data type

The data types in Python are divided in two


categories:
1. Immutable data types – Values cannot be changed.
2. Mutable data types – Values can be changed
Python Data Types
20

Immutable data types in Python are:


1. Numbers
2. String
3. Tuple

Mutable data types in Python are:


1. List
2. Dictionaries
3. Sets
Python Keywords and Identifiers
21

A Python keyword is a reserved word which you can’t use as a


name of your variable, class,
function etc.

These keywords have a special meaning and they are used for
special purposes in Python programming language. For example
– Python keyword “while” is used for while loop thus you can’t
name a variable with the name “while” else it may cause
compilation error.

There are total 33 keywords in Python 3.6.


Python Keywords and Identifiers
22

Here is a list of the Python keywords.

False def if raise


None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not class
from or continue global
pass
Laboratory Practice
Create a GitHub Repository
24

goto: https://github.com
• Log into your GitHub

Create your Repository


• Create Repo Name: dmoru883/dmoruCOS102

Open My Document from CMD Line


• Clone Repo: git clone <https…>

Create a folder Week_1 inside cloned repo


• Save your codes inside this folder

Commit Repo: git commit –m”Message”


• Push Repo: git push
Numeric Data Type in Python
25

Week_1/practice_1.pynb To run code: shift + enter


Python Data Type – String
26

Week_1/practice_2.pynb
Class Project
27

1. Design a flowchart and write a python program


for the following problems:
a) Simple Interest:
𝐴= 𝑃 ( 1 +(
𝑅
100
)𝑇 )
b) Compound Interest:
c) Annuity Plan:
(
𝐴= 𝑃 1+
𝑅
𝑛)𝑛𝑡

You might also like