SlideShare a Scribd company logo
Introduction to 
Programming with 
Python – Class 1 
SYED FARJAD ZIA ZAIDI
Class Objectives 
Class Objective 
Review variables, statements, expressions, functions, algorithms and technical 
terms. 
Understanding Flow Control. 
Write a simple program that performs addition, subtraction, multiplication and 
division using Functions.
Class Material 
•Chapter 1, 2, 3 - Python 
for Informatics: Exploring 
Information 
Reading 
Assignment •Rock, Paper, Scissors
Variables 
 Definition: 
A named piece of memory that can store a value. 
 Statement: 
A statement written in a programming language stores a value in a variable. 
Example: 
X = 5 
Y = 1 
 Expression: 
A variable that has a value can be used in an expression. 
Example: 
X = X + 4 
Y = X + 1
Rules for defining a Variable: 
 Names must start with a letter or _. 
 Names must contain only letters, digits, and _.
Questions?
Functions 
 Definition: 
A function is a block of organized, reusable code that is used to perform 
some action. 
 Defining a function: 
You can define a function in Python using the Keyword ‘def’. 
 General Form of Function: 
def function_name(parameters): 
body 
Example: 
def MyFirstFunction(): 
print “This is my first function in Python Programming Language”
Defining Functions 
You can define functions to provide the required functionality. Here 
are simple rules to define a function in Python. 
 Function blocks begin with the keyword ‘def’ followed by the 
function name and parentheses ‘( )’ . 
Example: 
def MyFirstFunction(): 
 Any input parameters or arguments should be placed within these 
parentheses. You can also define parameters inside these 
parentheses. 
Example: 
def MySecondFunction(passedInput):
Defining Functions 
 The first statement of a function can be an optional statement - the 
documentation string of the function or docstring. 
Example: 
def MyFirstFunction(): 
“””This is the 'docstring' which defines 
the function for other programmers to 
understand easily””” 
 The code block within every function starts with a colon (:) and is 
indented.
Defining Functions 
 The statement return [expression] exits a function, optionally passing 
back an expression to the caller. A return statement with no 
arguments is the same as return None. 
 General Form of Return Statement: 
return [expression] 
Example: 
def MyFunction(): 
“”“A function that returns a message””” 
return “This is a function that returns a message”
Calling a function 
 Function calls are expressions and the result can be stored in a 
variable. The general form of a function call: 
function_name(arguments) 
Example: 
MyFirstFunction() 
MySecondFunction(“Input Parameter”)
Questions?
Source Code vs Object Code 
Source Code Object Code 
Source Code is a text file version of 
a computer program or software that 
contains instructions that the 
computer follows to do something 
Object code, or sometimes an object 
module, is what a 
computer compiler produces 
Source code is written in 
a programming language which a 
human can read and change 
In a general sense object code is a 
sequence of statements or instructions 
in a computer language, usually 
a machine code language (i.e., 1's 
and 0's) 
Most source code is compiled when it 
is finished 
Object code is the resulting code 
after compiling source code
Compiler 
 A compiler is a computer program (or set of programs) that 
transforms source code written in a programming language (the 
source language) into another computer language (the target 
language, often having a binary form known as object code). The 
most common reason for wanting to transform source code is to 
create an executable program.
Questions?
Flow Control of the Program 
 Selection (If/Else) 
 Repetition (Loops)
Conditional Execution 
 In order to write useful programs, we almost always need to check 
some conditions and change the program accordingly. Conditional 
Statements gives us this ability. The simplest form is if statement. 
 General Form: 
if [expression1]: 
body1 
elif [expression2]: 
body2 
else: 
bodyN
Python Comparison Operators 
Operator Description 
== Checks if the value of two operands are equal or not, if yes 
then condition becomes true. 
!= Checks if the value of two operands are equal or not, if 
values are not equal then condition becomes true. 
< Checks if the value of left operand is less than the value of right 
operand, if yes then condition becomes true. 
> Checks if the value of left operand is greater than the value of right 
operand, if yes then condition becomes true. 
>= Checks if the value of left operand is greater than or equal 
to the value of right operand, if yes then condition becomes 
true. 
<= Checks if the value of left operand is less than or equal to 
the value of right operand, if yes then condition becomes 
true.
Python Logical Operators 
Operator Description 
and Called Logical AND operator. If both the operands are 
true then then condition becomes true. 
or Called Logical OR Operator. If any of the two operands 
are non zero then then condition becomes true. 
not Called Logical NOT Operator. Use to reverses the logical 
state of its operand. If a condition is true then Logical NOT 
operator will make false.
Questions?
Simple Calculator 
 Definition: 
A calculator is a machine which allows people to do math operations 
more easily. For example, most calculators will add, subtract, multiply, and 
divide. 
 Instructions for writing the Program: 
 There should be 4 functions in your program: 
 Add(number1, number2) 
 Subtract(number1, number2) 
 Multiply(number1, number2) 
 Divide(number1, number2) 
 The template for the program can be accessed here: 
http://www.codeskulptor.org/#user37_44o34rWsnC_18.py
Questions?
Rock Paper Scissors – 1st Mini- 
Project 
Rock-paper-scissors is a hand game that is played by two people. The 
players count to three in unison and simultaneously "throw” one of 
three hand signals that correspond to rock, paper or scissors. The 
winner is determined by the rules: 
 Rock smashes scissors 
 Scissors cuts paper 
 Paper covers rock
Instruction 
 In our first mini-project, we will build a Python function rps(name) 
that takes as input the string name, which is one of "rock", "paper", 
"scissors“. The function then simulates playing a round of rock-paper-scissors 
by calling a helper function gen_random_num() that 
generate own random choice from these alternatives and then 
determining the winner using simple if / else statements. 
 The mini-project template is here: 
http://www.codeskulptor.org/#user37_HJPdXx35jy_0.py
Example runs 
Player chooses rock 
Computer chooses scissors 
Player wins! 
Player chooses paper 
Computer chooses scissors 
Computer wins! 
Player chooses scissors 
Computer chooses paper 
Player wins!
Questions?

More Related Content

What's hot

Function
FunctionFunction
Function
MuhammadBakri13
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Python Fundamentals Class 11
Python Fundamentals Class 11Python Fundamentals Class 11
Python Fundamentals Class 11
chinthala Vijaya Kumar
 
Looping
LoopingLooping
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
Shakti Singh Rathore
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
Praveen M Jigajinni
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
Mohd Sajjad
 
Recursion CBSE Class 12
Recursion CBSE Class 12Recursion CBSE Class 12
Recursion CBSE Class 12
chinthala Vijaya Kumar
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
Mohd Sajjad
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
Pointers
PointersPointers
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
Devashish Kumar
 
The Awesome Python Class Part-2
The Awesome Python Class Part-2The Awesome Python Class Part-2
The Awesome Python Class Part-2
Binay Kumar Ray
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
Mohammed Sikander
 
Fun with lambda expressions
Fun with lambda expressionsFun with lambda expressions
Fun with lambda expressions
Mike Melusky
 
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov
 

What's hot (20)

Function
FunctionFunction
Function
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Python Fundamentals Class 11
Python Fundamentals Class 11Python Fundamentals Class 11
Python Fundamentals Class 11
 
Looping
LoopingLooping
Looping
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
 
Python-01| Fundamentals
Python-01| FundamentalsPython-01| Fundamentals
Python-01| Fundamentals
 
Recursion CBSE Class 12
Recursion CBSE Class 12Recursion CBSE Class 12
Recursion CBSE Class 12
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Pointers
PointersPointers
Pointers
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
 
The Awesome Python Class Part-2
The Awesome Python Class Part-2The Awesome Python Class Part-2
The Awesome Python Class Part-2
 
Python Built-in Functions and Use cases
Python Built-in Functions and Use casesPython Built-in Functions and Use cases
Python Built-in Functions and Use cases
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Fun with lambda expressions
Fun with lambda expressionsFun with lambda expressions
Fun with lambda expressions
 
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov, Introduction to Python, Lecture2
 

Viewers also liked

Cyberoam Firewall Presentation
Cyberoam Firewall PresentationCyberoam Firewall Presentation
Cyberoam Firewall Presentation
Manoj Kumar Mishra
 
Substituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scriptsSubstituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scripts
The HDF-EOS Tools and Information Center
 
Logic Over Language
Logic Over LanguageLogic Over Language
Logic Over Language
Purple, Rock, Scissors
 
Python and HDF5: Overview
Python and HDF5: OverviewPython and HDF5: Overview
Python and HDF5: Overview
andrewcollette
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
Syed Farjad Zia Zaidi
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
Syed Farjad Zia Zaidi
 
An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013
Syed Farjad Zia Zaidi
 
Logic: Language and Information 1
Logic: Language and Information 1Logic: Language and Information 1
Logic: Language and Information 1
Syed Farjad Zia Zaidi
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4
Syed Farjad Zia Zaidi
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBIRoy Lee
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arc
absvis
 
The Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5PyThe Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5Py
The HDF-EOS Tools and Information Center
 
Clase 2 estatica
Clase 2 estatica Clase 2 estatica
Clase 2 estatica
Gerald Moreira Ramírez
 
HDF5 Tools
HDF5 ToolsHDF5 Tools
Python programming - Everyday(ish) Examples
Python programming - Everyday(ish) ExamplesPython programming - Everyday(ish) Examples
Python programming - Everyday(ish) Examples
Ashish Sharma
 
Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
Kiran Gangadharan
 
introduction to python
introduction to pythonintroduction to python
introduction to python
Sardar Alam
 
Introduction to Python programming
Introduction to Python programmingIntroduction to Python programming
Introduction to Python programming
Damian T. Gordon
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Collaboration Technologies
 

Viewers also liked (20)

Cyberoam Firewall Presentation
Cyberoam Firewall PresentationCyberoam Firewall Presentation
Cyberoam Firewall Presentation
 
Substituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scriptsSubstituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scripts
 
Logic Over Language
Logic Over LanguageLogic Over Language
Logic Over Language
 
Python and HDF5: Overview
Python and HDF5: OverviewPython and HDF5: Overview
Python and HDF5: Overview
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
 
An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013
 
Logic: Language and Information 1
Logic: Language and Information 1Logic: Language and Information 1
Logic: Language and Information 1
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBI
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arc
 
The Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5PyThe Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5Py
 
Clase 2 estatica
Clase 2 estatica Clase 2 estatica
Clase 2 estatica
 
Using HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py moduleUsing HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py module
 
HDF5 Tools
HDF5 ToolsHDF5 Tools
HDF5 Tools
 
Python programming - Everyday(ish) Examples
Python programming - Everyday(ish) ExamplesPython programming - Everyday(ish) Examples
Python programming - Everyday(ish) Examples
 
Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
 
introduction to python
introduction to pythonintroduction to python
introduction to python
 
Introduction to Python programming
Introduction to Python programmingIntroduction to Python programming
Introduction to Python programming
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
 

Similar to Introduction To Programming with Python-1

An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
Raghu Kumar
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
Asst.prof M.Gokilavani
 
Lecture 08.pptx
Lecture 08.pptxLecture 08.pptx
Lecture 08.pptx
Mohammad Hassan
 
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONSINTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
KalaivaniD12
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
RojaPriya
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
kavinilavuG
 
Python functions
Python functionsPython functions
Python functions
Prof. Dr. K. Adisesha
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
SudhanshiBakre1
 
Python Functions.pptx
Python Functions.pptxPython Functions.pptx
Python Functions.pptx
AnuragBharti27
 
Python Functions.pptx
Python Functions.pptxPython Functions.pptx
Python Functions.pptx
AnuragBharti27
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
zynofustechnology
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
AnirudhaGaikwad4
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
mustafatahertotanawa1
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
Manas40552
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
YOGESH SINGH
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
Soham Kansodaria
 

Similar to Introduction To Programming with Python-1 (20)

An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
 
Lecture 08.pptx
Lecture 08.pptxLecture 08.pptx
Lecture 08.pptx
 
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONSINTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
INTRODUCTION TO PYTHON PROGRMMING AND FUNCTIONS
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python functions
Python functionsPython functions
Python functions
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
 
Python Functions.pptx
Python Functions.pptxPython Functions.pptx
Python Functions.pptx
 
Python Functions.pptx
Python Functions.pptxPython Functions.pptx
Python Functions.pptx
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
Pc module1
Pc module1Pc module1
Pc module1
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
 
Lecture1
Lecture1Lecture1
Lecture1
 
INTERNSHIP REPORT.docx
 INTERNSHIP REPORT.docx INTERNSHIP REPORT.docx
INTERNSHIP REPORT.docx
 

More from Syed Farjad Zia Zaidi

Vision & sight
Vision & sightVision & sight
Vision & sight
Syed Farjad Zia Zaidi
 
Introduction to Computing with Java
Introduction to Computing with JavaIntroduction to Computing with Java
Introduction to Computing with Java
Syed Farjad Zia Zaidi
 
Web Application Architectures
Web Application ArchitecturesWeb Application Architectures
Web Application Architectures
Syed Farjad Zia Zaidi
 
Foundations of Virtual Instruction
Foundations of Virtual InstructionFoundations of Virtual Instruction
Foundations of Virtual Instruction
Syed Farjad Zia Zaidi
 
Programming for Everybody (Python)
Programming for Everybody (Python)Programming for Everybody (Python)
Programming for Everybody (Python)
Syed Farjad Zia Zaidi
 
Learn to Program: The Fundamentals
Learn to Program: The FundamentalsLearn to Program: The Fundamentals
Learn to Program: The Fundamentals
Syed Farjad Zia Zaidi
 
Introduction to Systematic Program Design - Part 1
Introduction to Systematic Program Design - Part 1Introduction to Systematic Program Design - Part 1
Introduction to Systematic Program Design - Part 1
Syed Farjad Zia Zaidi
 
Emerging Trends & Technologies in the Virtual K-12 Classroom
Emerging Trends & Technologies in the Virtual K-12 ClassroomEmerging Trends & Technologies in the Virtual K-12 Classroom
Emerging Trends & Technologies in the Virtual K-12 Classroom
Syed Farjad Zia Zaidi
 
An Introduction to Interactive Programming in Python 2014
An Introduction to Interactive Programming in Python 2014An Introduction to Interactive Programming in Python 2014
An Introduction to Interactive Programming in Python 2014
Syed Farjad Zia Zaidi
 
Internet History, Technology, and Security
Internet History, Technology, and SecurityInternet History, Technology, and Security
Internet History, Technology, and Security
Syed Farjad Zia Zaidi
 
Human-Computer Interaction
Human-Computer InteractionHuman-Computer Interaction
Human-Computer Interaction
Syed Farjad Zia Zaidi
 
Beginning Game Programming with C#
Beginning Game Programming with C#Beginning Game Programming with C#
Beginning Game Programming with C#
Syed Farjad Zia Zaidi
 
Programming Mobile Applications for Android Handheld Systems 2014
Programming Mobile Applications for Android Handheld Systems 2014Programming Mobile Applications for Android Handheld Systems 2014
Programming Mobile Applications for Android Handheld Systems 2014
Syed Farjad Zia Zaidi
 
Computer Science 101
Computer Science 101Computer Science 101
Computer Science 101
Syed Farjad Zia Zaidi
 
Software Requirement Specification - Software Pack Solution 14
Software Requirement Specification - Software Pack Solution 14Software Requirement Specification - Software Pack Solution 14
Software Requirement Specification - Software Pack Solution 14
Syed Farjad Zia Zaidi
 
Project Proposal - Software Pack Solution 14
Project Proposal - Software Pack Solution 14Project Proposal - Software Pack Solution 14
Project Proposal - Software Pack Solution 14
Syed Farjad Zia Zaidi
 
Database Diagram Tutorial-SQL Server 2012
Database Diagram Tutorial-SQL Server 2012Database Diagram Tutorial-SQL Server 2012
Database Diagram Tutorial-SQL Server 2012
Syed Farjad Zia Zaidi
 
MindMuscle Xtreme
MindMuscle XtremeMindMuscle Xtreme
MindMuscle Xtreme
Syed Farjad Zia Zaidi
 
How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...
Syed Farjad Zia Zaidi
 
Level 1 DFD
Level 1 DFDLevel 1 DFD

More from Syed Farjad Zia Zaidi (20)

Vision & sight
Vision & sightVision & sight
Vision & sight
 
Introduction to Computing with Java
Introduction to Computing with JavaIntroduction to Computing with Java
Introduction to Computing with Java
 
Web Application Architectures
Web Application ArchitecturesWeb Application Architectures
Web Application Architectures
 
Foundations of Virtual Instruction
Foundations of Virtual InstructionFoundations of Virtual Instruction
Foundations of Virtual Instruction
 
Programming for Everybody (Python)
Programming for Everybody (Python)Programming for Everybody (Python)
Programming for Everybody (Python)
 
Learn to Program: The Fundamentals
Learn to Program: The FundamentalsLearn to Program: The Fundamentals
Learn to Program: The Fundamentals
 
Introduction to Systematic Program Design - Part 1
Introduction to Systematic Program Design - Part 1Introduction to Systematic Program Design - Part 1
Introduction to Systematic Program Design - Part 1
 
Emerging Trends & Technologies in the Virtual K-12 Classroom
Emerging Trends & Technologies in the Virtual K-12 ClassroomEmerging Trends & Technologies in the Virtual K-12 Classroom
Emerging Trends & Technologies in the Virtual K-12 Classroom
 
An Introduction to Interactive Programming in Python 2014
An Introduction to Interactive Programming in Python 2014An Introduction to Interactive Programming in Python 2014
An Introduction to Interactive Programming in Python 2014
 
Internet History, Technology, and Security
Internet History, Technology, and SecurityInternet History, Technology, and Security
Internet History, Technology, and Security
 
Human-Computer Interaction
Human-Computer InteractionHuman-Computer Interaction
Human-Computer Interaction
 
Beginning Game Programming with C#
Beginning Game Programming with C#Beginning Game Programming with C#
Beginning Game Programming with C#
 
Programming Mobile Applications for Android Handheld Systems 2014
Programming Mobile Applications for Android Handheld Systems 2014Programming Mobile Applications for Android Handheld Systems 2014
Programming Mobile Applications for Android Handheld Systems 2014
 
Computer Science 101
Computer Science 101Computer Science 101
Computer Science 101
 
Software Requirement Specification - Software Pack Solution 14
Software Requirement Specification - Software Pack Solution 14Software Requirement Specification - Software Pack Solution 14
Software Requirement Specification - Software Pack Solution 14
 
Project Proposal - Software Pack Solution 14
Project Proposal - Software Pack Solution 14Project Proposal - Software Pack Solution 14
Project Proposal - Software Pack Solution 14
 
Database Diagram Tutorial-SQL Server 2012
Database Diagram Tutorial-SQL Server 2012Database Diagram Tutorial-SQL Server 2012
Database Diagram Tutorial-SQL Server 2012
 
MindMuscle Xtreme
MindMuscle XtremeMindMuscle Xtreme
MindMuscle Xtreme
 
How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...How to connect database file to a 3-Tier Architecture Application and obtain ...
How to connect database file to a 3-Tier Architecture Application and obtain ...
 
Level 1 DFD
Level 1 DFDLevel 1 DFD
Level 1 DFD
 

Recently uploaded

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 

Recently uploaded (20)

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 

Introduction To Programming with Python-1

  • 1. Introduction to Programming with Python – Class 1 SYED FARJAD ZIA ZAIDI
  • 2. Class Objectives Class Objective Review variables, statements, expressions, functions, algorithms and technical terms. Understanding Flow Control. Write a simple program that performs addition, subtraction, multiplication and division using Functions.
  • 3. Class Material •Chapter 1, 2, 3 - Python for Informatics: Exploring Information Reading Assignment •Rock, Paper, Scissors
  • 4. Variables  Definition: A named piece of memory that can store a value.  Statement: A statement written in a programming language stores a value in a variable. Example: X = 5 Y = 1  Expression: A variable that has a value can be used in an expression. Example: X = X + 4 Y = X + 1
  • 5. Rules for defining a Variable:  Names must start with a letter or _.  Names must contain only letters, digits, and _.
  • 7. Functions  Definition: A function is a block of organized, reusable code that is used to perform some action.  Defining a function: You can define a function in Python using the Keyword ‘def’.  General Form of Function: def function_name(parameters): body Example: def MyFirstFunction(): print “This is my first function in Python Programming Language”
  • 8. Defining Functions You can define functions to provide the required functionality. Here are simple rules to define a function in Python.  Function blocks begin with the keyword ‘def’ followed by the function name and parentheses ‘( )’ . Example: def MyFirstFunction():  Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses. Example: def MySecondFunction(passedInput):
  • 9. Defining Functions  The first statement of a function can be an optional statement - the documentation string of the function or docstring. Example: def MyFirstFunction(): “””This is the 'docstring' which defines the function for other programmers to understand easily”””  The code block within every function starts with a colon (:) and is indented.
  • 10. Defining Functions  The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.  General Form of Return Statement: return [expression] Example: def MyFunction(): “”“A function that returns a message””” return “This is a function that returns a message”
  • 11. Calling a function  Function calls are expressions and the result can be stored in a variable. The general form of a function call: function_name(arguments) Example: MyFirstFunction() MySecondFunction(“Input Parameter”)
  • 13. Source Code vs Object Code Source Code Object Code Source Code is a text file version of a computer program or software that contains instructions that the computer follows to do something Object code, or sometimes an object module, is what a computer compiler produces Source code is written in a programming language which a human can read and change In a general sense object code is a sequence of statements or instructions in a computer language, usually a machine code language (i.e., 1's and 0's) Most source code is compiled when it is finished Object code is the resulting code after compiling source code
  • 14. Compiler  A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.
  • 16. Flow Control of the Program  Selection (If/Else)  Repetition (Loops)
  • 17. Conditional Execution  In order to write useful programs, we almost always need to check some conditions and change the program accordingly. Conditional Statements gives us this ability. The simplest form is if statement.  General Form: if [expression1]: body1 elif [expression2]: body2 else: bodyN
  • 18. Python Comparison Operators Operator Description == Checks if the value of two operands are equal or not, if yes then condition becomes true. != Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. < Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. > Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. >= Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. <= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.
  • 19. Python Logical Operators Operator Description and Called Logical AND operator. If both the operands are true then then condition becomes true. or Called Logical OR Operator. If any of the two operands are non zero then then condition becomes true. not Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.
  • 21. Simple Calculator  Definition: A calculator is a machine which allows people to do math operations more easily. For example, most calculators will add, subtract, multiply, and divide.  Instructions for writing the Program:  There should be 4 functions in your program:  Add(number1, number2)  Subtract(number1, number2)  Multiply(number1, number2)  Divide(number1, number2)  The template for the program can be accessed here: http://www.codeskulptor.org/#user37_44o34rWsnC_18.py
  • 23. Rock Paper Scissors – 1st Mini- Project Rock-paper-scissors is a hand game that is played by two people. The players count to three in unison and simultaneously "throw” one of three hand signals that correspond to rock, paper or scissors. The winner is determined by the rules:  Rock smashes scissors  Scissors cuts paper  Paper covers rock
  • 24. Instruction  In our first mini-project, we will build a Python function rps(name) that takes as input the string name, which is one of "rock", "paper", "scissors“. The function then simulates playing a round of rock-paper-scissors by calling a helper function gen_random_num() that generate own random choice from these alternatives and then determining the winner using simple if / else statements.  The mini-project template is here: http://www.codeskulptor.org/#user37_HJPdXx35jy_0.py
  • 25. Example runs Player chooses rock Computer chooses scissors Player wins! Player chooses paper Computer chooses scissors Computer wins! Player chooses scissors Computer chooses paper Player wins!