PPT
PPT
Batch:-Python
Introduction Of Python:-
Datatypes in python :-
Number
String List
a = 2.0
print(a, "is of type", type(a))
a = 1+2j
print(a, "is complex number?", isinstance(1+2j,complex))
5 is of type <class ‘int'>
my_string = "Hello“
print(my_string)
my_string = '''Hello''‘
print(my_string)
Hello
Hello
Hello
Hello, welcome to
the world of Python
List is an ordered collection of objects
(Int,Float,Bool,Str,List,Tuple,Dictionary,Set)
Example:-
x = ['apple', 3, [4.0, 5.0]] # multi-type list
Lists start counting from 0 on the left side (using +
numbers) and - 1 from the right side
+ index 0 1 2 3 4
- Index -5 -4 -3 -2 -1
Output:-
X[2] :- ‘Rock’
X[-5] :- ‘River’
Values in a dictionary are accessed via keys that are not just
numbers. They can be strings and other Python objects. Keys point
to values.
y = {}
y['Earth'] = 3
x['Venus'] * y ['Earth']
# this cannot be done with lists (need int indices)
Output:- 6
A set is an unordered collection of items.