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

Python Lecture 1

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

Python Lecture 1

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

Python

Let’s learn something New


Lecture 1
Variables
Data type
What is Python
• Python is simple & easy
• Free & Open Source
• High Level Language
• Developed by Guido van Rossum
• Portable
OUR First Program
print("Hello World")
Python Character Set

• Letters – A to Z, a to z
• Digits – 0 to 9
• Special Symbols - + - * / etc.
• Whitespaces – Blank Space, tab, carriage return, newline, form feed
• Other characters – Python can process all ASCII and Unicode
characters as part of data or literals
Variable
A variable is a name given to a memory location in a program.

• name = “Rahim"
• age = 23
• price = 25.99
Memory

• name = “Rahim"
• age = 23
• price = 25.99
Rules for Identifiers

1.Allowed Characters:
•Identifiers can only contain letters (A-Z or a-z), digits (0-9), and underscores (_).
2.Cannot Start with a Digit:
•An identifier cannot begin with a digit. For example, 123name is invalid, but name123 is valid.
3.Case Sensitivity:
•Identifiers are case-sensitive. For instance, variable, Variable, and VARIABLE are three different
identifiers.
4.No Reserved Words:
•Python keywords (like if, else, for, while, class, def, etc.) cannot be used as identifiers. You can find the
complete list of keywords by using:
Going on…

5. No Special Characters Allowed: @,!,$,#


6. Identifier can be on any length.
Data Type
• Integers
• String
• Float
• Boolean
• None
Types of operators
An operator is a symbol that performs a certain operation between
operands.

• Arithmetic Operators ( + , - , * , / , % , ** )
• Relational / Comparison Operators ( == , != , > , < , >= , <= )
• Assignment Operators ( = , +=, -= , *= , /= , %= , **= )
• Logical Operators ( not , and , or )
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

You might also like