0% found this document useful (0 votes)
5 views

Lecture1 Py

Uploaded by

cookieswarna
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture1 Py

Uploaded by

cookieswarna
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Python Programming

Prof. Deepika Dalavi

BCA Department
Institute of Engineering & Management
Automation?
The process of replacing a manual step with one that happens manually
Programmi
ng

Translator
(Compiler /
Interpreter)

Machin Cod
e e
Python is
• A general purpose scripting
language;

• A popular language used to code


a variety of applications;

• A frequently used tool for


automation;

• A cross-platform compatible
language;

• A beginner-friendly language.
Python is not
platform-specific / OS-specific scripting language;

a client-side scripting language;

a purely object-oriented programming language.


Common syntax errors

Misspellings
Incorrect indentations
Missing or incorrect key characters:
Bracket types - ( curved ), [ square ], { curly }
Quote types - "straight-double" or 'straight-single', “curly-double” or ‘curly-single’
Block introduction characters, like colons - :
Data type mismatches
Missing, incorrectly used, or misplaced Python reserved words
Using the wrong case (uppercase/lowercase) - Python is a case-sensitive
language
Common semantic errors
Creating functional code, but getting unintentional output

Poor logic structures in the design of the code


Programs in different scripting languages
Our First Program
Python Character
Set
Letters – A to Z, a
to z Digits – 0 to
9
Special Symbols -
+ - * / etc.
Whitespaces –
Blank Space, tab,
carriage return,
newline, formfeed
Other characters
– Python can
process all ASCII
and Unicode
Variables
A variable is a name given to a memory location in
a program.

name =
"Deepika" age
= 23
price = 25.99
Memory

name =
"Deepika" age
= 23
price = 25.99
Rules for
Identifiers
Data Types
Integer
s

String

Float

Boolea

n None
Data Types
Keywords
Keywords are reserved words in
python.

*False should be
uppercase
Print Sum
Comments in
Python
# Single Line
Comment

"""
Multi Line
Comment
"""
Types of
Operators
An operator is a symbol that performs a certain operation
between operands.

Arithmetic Operators ( + , - , * , / , % , * * )

Relational / Comparison Operators ( == , != , > ,

< , >= , <= ) Assignment Operators ( = , +=, -

= , *= , /= , %= , **= )
PEDMAS
The order of operations are to be calculated from left to right in the following
order:

Parentheses ( ), { }, [ ]

Exponents xy (x**y)

Multiplication * and Division /

Addition + and Subtraction -


Type Conversion

a, b = 1,
2.0
sum = a + b

#error
a, b = 1,
"2"
sum = a + b
Type Casting

a, b = 1,
"2"
c = int(b)
sum = a + c
Type Casting
Input in Python
input( ) statement is used to accept values (using keyboard)
from user

input( ) #result for input( ) is always a


str

int ( input( ) ) #int

float ( input( ) ) #float


Let‘s Practice
Write a Program to input 2 numbers & print their
sum.
Let‘s Practice
WAP to input side of a square & print its
area.
Let‘s Practice
WAP to input 2 floating point numbers & print their
average.
Let‘s Practice
WAP to input 2 int numbers, a and b.
Print True if a is greater than or equal to b. If not print
False.

You might also like