Variable and Assignments
Variables represent memory location, whose values can be manipulated or changed during
execution of the program.
Example: NAME= ”RAHUL KUMAR”
Multiple Assignments
• Assigning same value to multiple variable
a = b = 50
• Assigning multiple values to multiple variables
a , b = 50, 100
SIMPLE INPUT AND OUTPUT
Input( ): it is used to take the value from users.
Examples:
name= input("enter your name")
age=int(input("enter your age"))
print( ): it is used to print the output /result.
Examples:
print("oxford","public","school")
output: oxford public school
sep argument
print("oxford","public","school", sep="#")
output: oxford#public#school
end argument
print("wel come to", end=" ")
print("oxford public school")
output: wel come to oxford public school
Data Types
Data types are means to identify type of data and set of valid operations for it
Core Data Types
Numbers Sets Sequences Mappings
Floating
Integer point Complex String Tuple List Dictionary
Boolean
Python data type can be categorized into two category:
Mutable Data type: the mutable types are those that can change their
value in place.
Example: List, Dictionary
Immutable Data type: the immutable types are those that can never
change their value in place.
Example: String, Tuple
Data types for Numbers:
•Integers:
Integers
Boolean
•Floating Point Numbers
•Complex Numbers
String:
A string data type can hold any string data i.e. any number of valid
characters into a set of quotation marks.
school="OXFORD"
0 1 2 3 4 5
INDEX
O X F O R D
-6 -5 -4 -3 -2 -1
Lists:
A List represents a group of comma-separated values of any data
type within square brackets.
L=[ 2, 4, 6, 8 ]
L1=[100, "Rohit","Ranchi"]
Tuples:
A Tuple represents a group of comma-separated values of any data
type within parentheses.
T=( 1, 2, 3, 4 )
T=( 100, "Rohit","Ranchi" )
Dictionaries:
Dictionary is an unordered set of comma-separeted key : value pairs
within { }.
D={1:300, 2:200, 3:400}
Sets: sets are similar to lists that can store multiple values same as in
mathematical sets. The elements are unordered and mutable data type.
A set cannot contain mutable elements in it.
S={1,2,3,4,5,6}
S={1,2,3,4,5,5} # Duplicate value not allow
S={1,2,3,4,[5,6]} # mutable value not allow