Programming in Phyton - Sequence
Programming in Phyton - Sequence
PHYTON:
Sequence
Introduction
• Any task that we perform include a various step.
• Computer follows stepwise instructions to complete any task which is known as
Program.
• E.g., game or application
• A program consist of set of instructions.
• Three basics programming construct: Sequence, Selection, Iteration.
• The language used to write programs is called Programming Language.
• There are many different programming language use to write computer programs.
• E.g., Java, Ruby, JavaScript, SQL, Python and many more!
• The person who writes the programs is known as programmer.
Programming
Constructs
• Sequence is the order in which
instructions occur and are
processed.
• Selection determines which path
a program takes when it is
running.
• Iteration is the repeated
execution of a section of code
when a program is running
Python is a computer programming language often
used to build websites and software, automate
tasks, and conduct data analysis. Python is a
general-purpose language, meaning it can be used to
create a variety of different programs and isn't
specialized for any specific problems.
Why
?
• It’s Free!
• Easy to learn
• Exceptionally powerful
• Universally accepted,
• Effective
• Superb Learning and Educational too.
What can you do with
?
• Web Development
• Software Development
• Gaming
• Artificial Intelligence
Using IDLE
x=5
You can put any name to variable. BUT MUST FOLLOW THESE RULES:
Output:
CHAPTER: PROGRAMMING IN PHYTON
Data Types
Data types is a classification of data. There are 3 common data types: Strings, Integers, and
Floating-Point Numbers (Real numbers).
e.g. pi = 3.15 Floating point number
radius = 6 Integer
Data entered after an input prompt is a string unless we tell it otherwise. Telling the computer
what type of data to expect is called typecasting or casting.
Code: What this code do?
- First, it will ask user to enter first number and
convert number in string into the number in
integer
- Second, it will ask user to enter second
Output: number and convert number in string into the
number in integer
- Next it will total up the number by calling the
variable name.
CHAPTER: PROGRAMMING IN PHYTON
Constants
Sometimes we use the same value more than once in a program. We can avoid having to
type the value each time by specifying constant.
In python, the value of the constant is state at the very beginning of the program and then call
on it when it is needed.
Example:
Constants
pi=3.14
radius=int(input("Enter circle radius: "))
area=pi*radius*radius
print("The circle area is " + str(area))
CHAPTER: PROGRAMMING IN PHYTON
Placeholder
There are another option for combining output other than using concatenation (+). We can
use placeholder.