Lecture1_py."…………lol.lll.lll.………………..……..

RoshanKumar419236 24 views 21 slides May 29, 2024
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

Python


Slide Content

Programming
Translator
Machine Code
(Compiler / Interpreter)Apna College

What is Python?
Python is simple & easy
Free & Open Source
High Level Language
Developed by Guido van Rossum
PortableApna College

Our First Program
print("Hello World")Apna College

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 characters as part of data or literalsApna College

Variables
name = "Shradha"
age = 23
price = 25.99
A variable is a name given to a memory location in a program.Apna College

Memory
name = "Shradha"
age = 23
price = 25.99Apna College

Rules for IdentifiersApna College

Data Types
Integers
String
Float
Boolean
NoneApna College

Data TypesApna College

Keywords
Keywords are reserved words in python.
*False should be uppercase Apna College

Print SumApna College

# Single Line Comment
"""
Multi Line
Comment
"""
Comments in PythonApna College

Arithmetic Operators ( + , - , * , / , % , ** )
Relational / Comparison Operators ( == , != , > , < , >= , <= )
Assignment Operators ( = , +=, -= , *= , /= , %= , **= )
Logical Operators ( not , and , or )
Types of Operators
An operator is a symbol that performs a certain operation between operands.Apna College

Type Conversion
a, b = 1, 2.0
sum = a + b
a, b = 1, "2"
sum = a + b
#errorApna College

Type Casting
a, b = 1, "2"
c = int(b)
sum = a + cApna College

Type Casting Apna College

int ( input( ) ) #int
Input in Python
input( ) #result for input( ) is always a str
float ( input( ) ) #float
give code eg of all 3
input( ) statement is used to accept values (using keyboard) from userApna College

Let‘s Practice
Write a Program to input 2 numbers & print their sum.Apna College

Let‘s Practice
WAP to input side of a square & print its area.Apna College

Let‘s Practice
WAP to input 2 floating point numbers & print their average.Apna College

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.Apna College
Tags