SlideShare a Scribd company logo
1
2
What is Scripting Language?
A scripting language is a “wrapper” language that integrates OS
functions.
• The interpreter is a layer of software logic between your code
and the computer hardware on your machine. Wiki Says:
• The “program” has an executable form that the computer can
use directly to execute the instructions.
• The same program in its human-readable source code form,
from which executable programs are derived (e.g., compiled) •
Python is scripting language, fast and dynamic.
• Python is called ‘scripting language’ because of it’s scalable
interpreter, but actually it is much more than that
3
What is Python?
Python is a high-level programming language which is:
 Interpreted: Python is processed at runtime by the interpreter.
(Next Slide)
 Interactive: You can use a Python prompt and interact with the
interpreter directly to write your programs.
 Object-Oriented: Python supports Object-Oriented technique of
programming.
 Beginner’s Language: Python is a great language for the
beginner-level programmers and supports the development of a
wide range of applications. 8/22/201
4
 Some influential ones:
 FORTRAN
 science / engineering
 COBOL
 business data
 LISP
 logic and AI
 BASIC
 a simple language
Languages
5
 code or source code: The sequence of instructions in a program.
 syntax: The set of legal structures and commands that can be
used in a particular programming language.
 output: The messages printed to the user by a program.
 console: The text box onto which output is printed.
 Some source code editors pop up the console as an external window,
and others contain their own console window.
Programming basics
6
Compiling and interpreting
 Many languages require you to compile (translate) your program
into a form that the machine understands.
 Python is instead directly interpreted into machine instructions.
compile execute
outputsource code
Hello.java
byte code
Hello.class
interpret
outputsource code
Hello.py
7
Expressions
 expression: A data value or set of operations to compute a value.
Examples: 1 + 4 * 3
42
 Arithmetic operators we will use:
 + - * / addition, subtraction/negation, multiplication, division
 % modulus, a.k.a. remainder
 ** exponentiation
 precedence: Order in which operations are computed.
 * / % ** have a higher precedence than + -
1 + 3 * 4 is 13
 Parentheses can be used to force a certain order of evaluation.
(1 + 3) * 4 is 16
8
Integer division
 When we divide integers with / , the quotient is also an integer.
3 52
4 ) 14 27 ) 1425
12 135
2 75
54
21
 More examples:
 35 / 5 is 7
 84 / 10 is 8
 156 / 100 is 1
 The % operator computes the remainder from a division of integers.
3 43
4 ) 14 5 ) 218
12 20
2 18
15
3
9
Real numbers
 Python can also manipulate real numbers.
 Examples: 6.022 -15.9997 42.0 2.143e17
 The operators + - * / % ** ( ) all work for real numbers.
 The / produces an exact answer: 15.0 / 2.0 is 7.5
 The same rules of precedence also apply to real numbers:
Evaluate ( ) before * / % before + -
 When integers and reals are mixed, the result is a real number.
 Example: 1 / 2.0 is 0.5
 The conversion occurs on a per-operator basis.
 7 / 3 * 1.2 + 3 / 2
 2 * 1.2 + 3 / 2
 2.4 + 3 / 2
 2.4 + 1
 3.4
10
 print : Produces text output on the console.
 Syntax:
print "Message"
print Expression
 Prints the given text message or expression value on the console, and
moves the cursor down to the next line.
print Item1, Item2, ..., ItemN
 Prints several messages and/or expressions on the same line.
 Examples:
print "Hello, world!"
age = 45
print "You have", 65 - age, "years until retirement"
Output:
Hello, world!
You have 20 years until retirement
print
11
 input : Reads a number from user input.
 You can assign (store) the result of input into a variable.
 Example:
age = input("How old are you? ")
print "Your age is", age
print "You have", 65 - age, "years until retirement"
Output:
How old are you? 53
Your age is 53
You have 12 years until retirement
 Exercise: Write a Python program that prompts the user for
his/her amount of money, then reports how many Nintendo Wiis
the person can afford, and how much more money he/she will
need to afford an additional Wii.
input
12
The for loop
 for loop: Repeats a set of statements over a group of values.
 Syntax:
for variableName in groupOfValues:
statements
 We indent the statements to be repeated with tabs or spaces.
 variableName gives a name to each value, so you can refer to it in the statements.
 groupOfValues can be a range of integers, specified with the range function.
 Example:
for x in range(1, 6):
print x, "squared is", x * x
Output:
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
13
Cumulative loops
 Some loops incrementally compute a value that is initialized outside
the loop. This is sometimes called a cumulative sum.
sum = 0
for i in range(1, 11):
sum = sum + (i * i)
print "sum of first 10 squares is", sum
Output:
sum of first 10 squares is 385
 Exercise: Write a Python program that computes the factorial of an
integer.
14
if
 if statement: Executes a group of statements only if a certain
condition is true. Otherwise, the statements are skipped.
 Syntax:
if condition:
statements
 Example:
gpa = 3.4
if gpa > 2.0:
print "Your application is accepted."
15
if/else
 if/else statement: Executes one block of statements if a certain
condition is True, and a second block of statements if it is False.
 Syntax:
if condition:
statements
else:
statements
 Example:
gpa = 1.4
if gpa > 2.0:
print "Welcome to Mars University!"
else:
print "Your application is denied."
 Multiple conditions can be chained with elif ("else if"):
if condition:
statements
elif condition:
statements
else:
statements
16
while
 while loop: Executes a group of statements as long as a condition is True.
 good for indefinite loops (repeat an unknown number of times)
 Syntax:
while condition:
statements
 Example:
number = 1
while number < 200:
print number,
number = number * 2
 Output:
1 2 4 8 16 32 64 128
17
File processing
 Many programs handle data, which often comes from files.
 Reading the entire contents of a file:
variableName = open("filename").read()
Example:
file_text = open("bankaccount.txt").read()
A reputed online tutor, Maja Kazazic
has working as a teacher
for a number of years now. He
provides tutorship mainly in subjects
like Programming language Python ,
Java Etc. His teaching methods are
unique and innovative. He works
hard to make sure every student
excels under her tutelage. He has
also written several academic blogs
at Visit:
https://helpmeinhomework.com/online-python-assignment-help/

More Related Content

What's hot

Python Basics
Python BasicsPython Basics
Python Basics
Pooja B S
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
Programming
ProgrammingProgramming
Programming
monishagoyal4
 
C programming notes
C programming notesC programming notes
C programming notes
Prof. Dr. K. Adisesha
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
Prakash Jayaraman
 
programming concept
programming conceptprogramming concept
programming concept
Nehabhy
 
Python programming introduction
Python programming introductionPython programming introduction
Python programming introduction
Siddique Ibrahim
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
deepak teja
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
stn_tkiller
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Aniket tore
Aniket toreAniket tore
Aniket tore
anikettore1
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
Ruth Marvin
 
Python basics
Python basicsPython basics
Python basics
RANAALIMAJEEDRAJPUT
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik
 
Notes1
Notes1Notes1
Notes1hccit
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ranjith kumar
 
Python by Rj
Python by RjPython by Rj
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
Dr.YNM
 

What's hot (20)

Python Basics
Python BasicsPython Basics
Python Basics
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Programming
ProgrammingProgramming
Programming
 
C programming notes
C programming notesC programming notes
C programming notes
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
programming concept
programming conceptprogramming concept
programming concept
 
Python programming introduction
Python programming introductionPython programming introduction
Python programming introduction
 
Python introduction towards data science
Python introduction towards data sciencePython introduction towards data science
Python introduction towards data science
 
Python - Introduction
Python - IntroductionPython - Introduction
Python - Introduction
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Learn python
Learn pythonLearn python
Learn python
 
Notes1
Notes1Notes1
Notes1
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 

Similar to Help with Pyhon Programming Homework

lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
ExcellenceAcadmy
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
ExcellenceAcadmy
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
PhanMinhLinhAnxM0190
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
RohitSindhu10
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
AkashdeepBhattacharj1
 
Python programing
Python programingPython programing
Python programing
hamzagame
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
App Ttrainers .com
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
Sasidhar Kothuru
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa Thapa
 
Python
PythonPython
Python
MeHak Gulati
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
AkramWaseem
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
KosmikTech1
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
00 C hello world.pptx
00 C hello world.pptx00 C hello world.pptx
00 C hello world.pptx
Carla227537
 

Similar to Help with Pyhon Programming Homework (20)

lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)Python Training in Chandigarh(Mohali)
Python Training in Chandigarh(Mohali)
 
Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)Python Training Course in Chandigarh(Mohali)
Python Training Course in Chandigarh(Mohali)
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 
python notes.pdf
python notes.pdfpython notes.pdf
python notes.pdf
 
python 34💭.pdf
python 34💭.pdfpython 34💭.pdf
python 34💭.pdf
 
Python programing
Python programingPython programing
Python programing
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Python basics
Python basicsPython basics
Python basics
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 
Python
PythonPython
Python
 
python introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptxpython introduction initial lecture unit1.pptx
python introduction initial lecture unit1.pptx
 
Python Tutorial
Python TutorialPython Tutorial
Python Tutorial
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
00 C hello world.pptx
00 C hello world.pptx00 C hello world.pptx
00 C hello world.pptx
 
My final requirement
My final requirementMy final requirement
My final requirement
 

Recently uploaded

Summary of financial results for 1Q2024
Summary of financial  results for 1Q2024Summary of financial  results for 1Q2024
Summary of financial results for 1Q2024
InterCars
 
Which Crypto to Buy Today for Short-Term in May-June 2024.pdf
Which Crypto to Buy Today for Short-Term in May-June 2024.pdfWhich Crypto to Buy Today for Short-Term in May-June 2024.pdf
Which Crypto to Buy Today for Short-Term in May-June 2024.pdf
Kezex (KZX)
 
Isios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdfIsios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdf
Henry Tapper
 
Latino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino CaucusLatino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino Caucus
Danay Escanaverino
 
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit CardPoonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
nickysharmasucks
 
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
Amil baba
 
655264371-checkpoint-science-past-papers-april-2023.pdf
655264371-checkpoint-science-past-papers-april-2023.pdf655264371-checkpoint-science-past-papers-april-2023.pdf
655264371-checkpoint-science-past-papers-april-2023.pdf
morearsh02
 
how to sell pi coins on Bitmart crypto exchange
how to sell pi coins on Bitmart crypto exchangehow to sell pi coins on Bitmart crypto exchange
how to sell pi coins on Bitmart crypto exchange
DOT TECH
 
how to sell pi coins in South Korea profitably.
how to sell pi coins in South Korea profitably.how to sell pi coins in South Korea profitably.
how to sell pi coins in South Korea profitably.
DOT TECH
 
The European Unemployment Puzzle: implications from population aging
The European Unemployment Puzzle: implications from population agingThe European Unemployment Puzzle: implications from population aging
The European Unemployment Puzzle: implications from population aging
GRAPE
 
What website can I sell pi coins securely.
What website can I sell pi coins securely.What website can I sell pi coins securely.
What website can I sell pi coins securely.
DOT TECH
 
Greek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business ReviewGreek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business Review
Antonis Zairis
 
Turin Startup Ecosystem 2024 - Ricerca sulle Startup e il Sistema dell'Innov...
Turin Startup Ecosystem 2024  - Ricerca sulle Startup e il Sistema dell'Innov...Turin Startup Ecosystem 2024  - Ricerca sulle Startup e il Sistema dell'Innov...
Turin Startup Ecosystem 2024 - Ricerca sulle Startup e il Sistema dell'Innov...
Quotidiano Piemontese
 
Proposer Builder Separation Problem in Ethereum
Proposer Builder Separation Problem in EthereumProposer Builder Separation Problem in Ethereum
Proposer Builder Separation Problem in Ethereum
RasoulRamezanian1
 
Introduction to Indian Financial System ()
Introduction to Indian Financial System ()Introduction to Indian Financial System ()
Introduction to Indian Financial System ()
Avanish Goel
 
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad, Mandi Bah...
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad,  Mandi Bah...NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad,  Mandi Bah...
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad, Mandi Bah...
Amil Baba Dawood bangali
 
Commercial Bank Economic Capsule - May 2024
Commercial Bank Economic Capsule - May 2024Commercial Bank Economic Capsule - May 2024
Commercial Bank Economic Capsule - May 2024
Commercial Bank of Ceylon PLC
 
The secret way to sell pi coins effortlessly.
The secret way to sell pi coins effortlessly.The secret way to sell pi coins effortlessly.
The secret way to sell pi coins effortlessly.
DOT TECH
 
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
ydubwyt
 
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
betoozp
 

Recently uploaded (20)

Summary of financial results for 1Q2024
Summary of financial  results for 1Q2024Summary of financial  results for 1Q2024
Summary of financial results for 1Q2024
 
Which Crypto to Buy Today for Short-Term in May-June 2024.pdf
Which Crypto to Buy Today for Short-Term in May-June 2024.pdfWhich Crypto to Buy Today for Short-Term in May-June 2024.pdf
Which Crypto to Buy Today for Short-Term in May-June 2024.pdf
 
Isios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdfIsios-2024-Professional-Independent-Trustee-Survey.pdf
Isios-2024-Professional-Independent-Trustee-Survey.pdf
 
Latino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino CaucusLatino Buying Power - May 2024 Presentation for Latino Caucus
Latino Buying Power - May 2024 Presentation for Latino Caucus
 
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit CardPoonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
Poonawalla Fincorp and IndusInd Bank Introduce New Co-Branded Credit Card
 
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
NO1 Uk Rohani Baba In Karachi Bangali Baba Karachi Online Amil Baba WorldWide...
 
655264371-checkpoint-science-past-papers-april-2023.pdf
655264371-checkpoint-science-past-papers-april-2023.pdf655264371-checkpoint-science-past-papers-april-2023.pdf
655264371-checkpoint-science-past-papers-april-2023.pdf
 
how to sell pi coins on Bitmart crypto exchange
how to sell pi coins on Bitmart crypto exchangehow to sell pi coins on Bitmart crypto exchange
how to sell pi coins on Bitmart crypto exchange
 
how to sell pi coins in South Korea profitably.
how to sell pi coins in South Korea profitably.how to sell pi coins in South Korea profitably.
how to sell pi coins in South Korea profitably.
 
The European Unemployment Puzzle: implications from population aging
The European Unemployment Puzzle: implications from population agingThe European Unemployment Puzzle: implications from population aging
The European Unemployment Puzzle: implications from population aging
 
What website can I sell pi coins securely.
What website can I sell pi coins securely.What website can I sell pi coins securely.
What website can I sell pi coins securely.
 
Greek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business ReviewGreek trade a pillar of dynamic economic growth - European Business Review
Greek trade a pillar of dynamic economic growth - European Business Review
 
Turin Startup Ecosystem 2024 - Ricerca sulle Startup e il Sistema dell'Innov...
Turin Startup Ecosystem 2024  - Ricerca sulle Startup e il Sistema dell'Innov...Turin Startup Ecosystem 2024  - Ricerca sulle Startup e il Sistema dell'Innov...
Turin Startup Ecosystem 2024 - Ricerca sulle Startup e il Sistema dell'Innov...
 
Proposer Builder Separation Problem in Ethereum
Proposer Builder Separation Problem in EthereumProposer Builder Separation Problem in Ethereum
Proposer Builder Separation Problem in Ethereum
 
Introduction to Indian Financial System ()
Introduction to Indian Financial System ()Introduction to Indian Financial System ()
Introduction to Indian Financial System ()
 
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad, Mandi Bah...
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad,  Mandi Bah...NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad,  Mandi Bah...
NO1 Uk Black Magic Specialist Expert In Sahiwal, Okara, Hafizabad, Mandi Bah...
 
Commercial Bank Economic Capsule - May 2024
Commercial Bank Economic Capsule - May 2024Commercial Bank Economic Capsule - May 2024
Commercial Bank Economic Capsule - May 2024
 
The secret way to sell pi coins effortlessly.
The secret way to sell pi coins effortlessly.The secret way to sell pi coins effortlessly.
The secret way to sell pi coins effortlessly.
 
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
一比一原版UOL毕业证利物浦大学毕业证成绩单如何办理
 
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
一比一原版Birmingham毕业证伯明翰大学|学院毕业证成绩单如何办理
 

Help with Pyhon Programming Homework

  • 1. 1
  • 2. 2 What is Scripting Language? A scripting language is a “wrapper” language that integrates OS functions. • The interpreter is a layer of software logic between your code and the computer hardware on your machine. Wiki Says: • The “program” has an executable form that the computer can use directly to execute the instructions. • The same program in its human-readable source code form, from which executable programs are derived (e.g., compiled) • Python is scripting language, fast and dynamic. • Python is called ‘scripting language’ because of it’s scalable interpreter, but actually it is much more than that
  • 3. 3 What is Python? Python is a high-level programming language which is:  Interpreted: Python is processed at runtime by the interpreter. (Next Slide)  Interactive: You can use a Python prompt and interact with the interpreter directly to write your programs.  Object-Oriented: Python supports Object-Oriented technique of programming.  Beginner’s Language: Python is a great language for the beginner-level programmers and supports the development of a wide range of applications. 8/22/201
  • 4. 4  Some influential ones:  FORTRAN  science / engineering  COBOL  business data  LISP  logic and AI  BASIC  a simple language Languages
  • 5. 5  code or source code: The sequence of instructions in a program.  syntax: The set of legal structures and commands that can be used in a particular programming language.  output: The messages printed to the user by a program.  console: The text box onto which output is printed.  Some source code editors pop up the console as an external window, and others contain their own console window. Programming basics
  • 6. 6 Compiling and interpreting  Many languages require you to compile (translate) your program into a form that the machine understands.  Python is instead directly interpreted into machine instructions. compile execute outputsource code Hello.java byte code Hello.class interpret outputsource code Hello.py
  • 7. 7 Expressions  expression: A data value or set of operations to compute a value. Examples: 1 + 4 * 3 42  Arithmetic operators we will use:  + - * / addition, subtraction/negation, multiplication, division  % modulus, a.k.a. remainder  ** exponentiation  precedence: Order in which operations are computed.  * / % ** have a higher precedence than + - 1 + 3 * 4 is 13  Parentheses can be used to force a certain order of evaluation. (1 + 3) * 4 is 16
  • 8. 8 Integer division  When we divide integers with / , the quotient is also an integer. 3 52 4 ) 14 27 ) 1425 12 135 2 75 54 21  More examples:  35 / 5 is 7  84 / 10 is 8  156 / 100 is 1  The % operator computes the remainder from a division of integers. 3 43 4 ) 14 5 ) 218 12 20 2 18 15 3
  • 9. 9 Real numbers  Python can also manipulate real numbers.  Examples: 6.022 -15.9997 42.0 2.143e17  The operators + - * / % ** ( ) all work for real numbers.  The / produces an exact answer: 15.0 / 2.0 is 7.5  The same rules of precedence also apply to real numbers: Evaluate ( ) before * / % before + -  When integers and reals are mixed, the result is a real number.  Example: 1 / 2.0 is 0.5  The conversion occurs on a per-operator basis.  7 / 3 * 1.2 + 3 / 2  2 * 1.2 + 3 / 2  2.4 + 3 / 2  2.4 + 1  3.4
  • 10. 10  print : Produces text output on the console.  Syntax: print "Message" print Expression  Prints the given text message or expression value on the console, and moves the cursor down to the next line. print Item1, Item2, ..., ItemN  Prints several messages and/or expressions on the same line.  Examples: print "Hello, world!" age = 45 print "You have", 65 - age, "years until retirement" Output: Hello, world! You have 20 years until retirement print
  • 11. 11  input : Reads a number from user input.  You can assign (store) the result of input into a variable.  Example: age = input("How old are you? ") print "Your age is", age print "You have", 65 - age, "years until retirement" Output: How old are you? 53 Your age is 53 You have 12 years until retirement  Exercise: Write a Python program that prompts the user for his/her amount of money, then reports how many Nintendo Wiis the person can afford, and how much more money he/she will need to afford an additional Wii. input
  • 12. 12 The for loop  for loop: Repeats a set of statements over a group of values.  Syntax: for variableName in groupOfValues: statements  We indent the statements to be repeated with tabs or spaces.  variableName gives a name to each value, so you can refer to it in the statements.  groupOfValues can be a range of integers, specified with the range function.  Example: for x in range(1, 6): print x, "squared is", x * x Output: 1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16 5 squared is 25
  • 13. 13 Cumulative loops  Some loops incrementally compute a value that is initialized outside the loop. This is sometimes called a cumulative sum. sum = 0 for i in range(1, 11): sum = sum + (i * i) print "sum of first 10 squares is", sum Output: sum of first 10 squares is 385  Exercise: Write a Python program that computes the factorial of an integer.
  • 14. 14 if  if statement: Executes a group of statements only if a certain condition is true. Otherwise, the statements are skipped.  Syntax: if condition: statements  Example: gpa = 3.4 if gpa > 2.0: print "Your application is accepted."
  • 15. 15 if/else  if/else statement: Executes one block of statements if a certain condition is True, and a second block of statements if it is False.  Syntax: if condition: statements else: statements  Example: gpa = 1.4 if gpa > 2.0: print "Welcome to Mars University!" else: print "Your application is denied."  Multiple conditions can be chained with elif ("else if"): if condition: statements elif condition: statements else: statements
  • 16. 16 while  while loop: Executes a group of statements as long as a condition is True.  good for indefinite loops (repeat an unknown number of times)  Syntax: while condition: statements  Example: number = 1 while number < 200: print number, number = number * 2  Output: 1 2 4 8 16 32 64 128
  • 17. 17 File processing  Many programs handle data, which often comes from files.  Reading the entire contents of a file: variableName = open("filename").read() Example: file_text = open("bankaccount.txt").read()
  • 18. A reputed online tutor, Maja Kazazic has working as a teacher for a number of years now. He provides tutorship mainly in subjects like Programming language Python , Java Etc. His teaching methods are unique and innovative. He works hard to make sure every student excels under her tutelage. He has also written several academic blogs at Visit: https://helpmeinhomework.com/online-python-assignment-help/