Lecture1 Py
Lecture1 Py
Translator
(CompŤler / Interpreter)
MachŤne Code
What Ťs Python?
Python Ťs sŤmple &
Language
Portable
O u r F Ťr s t P r o g r a m
print("Hello World")
Python Character Set
Letters – A to Z, a to
z DŤgŤts – 0 to 9
SpecŤal Symbols - + - * / etc.
WhŤtespaces – Blank Space, tab, carrŤage return, newlŤne, formfeed
Other characters – Python can process all ASCII and UnŤcode characters as part of data or lŤterals
VarŤables
A varŤable Ťs a name gŤven to a memory locatŤon Ťn a program.
name =
"Shradha" age =
23
price = 25.99
Memory
name =
"Shradha" age =
23
price = 25.99
Rules for IdentŤfŤers
Data Types
Integers
StrŤng
Float
Boolean
None
Data Types
Keywords
Keywords are reserved words Ťn python.
"""
Multi Line
Comment
"""
Types of Operators
An operator Ťs a symbol that performs a certaŤn operatŤon between operands.
ArŤthmetŤc Operators ( + , - , * , / , % , ** )
a, b = 1, 2.0
sum = a + b
#error
a, b = 1, "2"
sum = a + b
Type CastŤng
a, b = 1, "2"
c = int(b)
sum = a + c
Type CastŤng
Input Ťn Python
Ťnput( ) statement Ťs used to accept values (usŤng keyboard) from user