2nd Python Full Stack Online
2nd Python Full Stack Online
Step1 : Open the chrome and give a suggestion as download python for windows
Step2 : Now the link is redirected into python community click on that and you can download the
python over there
Step3 : Or else click the given link below
https://www.python.org/downloads/
Step4: Now the download the python
""""
Variable is a container which holds information
Ways to create a variable
1. A varialble starts with a Capital letter(A-Z)
2. A Variable can also start with a small Letter(a-z)
3.A variable can also start with an underscore(_)
Ways not to create a variable
1. A Variable should not start with a digit
2. A variable should not start with a reserved/keywords
"""
print(abbccc)
_123= "hello"
print(_123)
_A= 123
print(_A)
#123 = 123--bad
Python Datatypes
The python datatype tells about the type of data that a
variable is holding on…
1.Number
2.Sequence
3.Bool
4.Set
5.Dictionary
1.Number Datatype()
a = 123
print(a)
print(type(a))#<class 'int'>
print(id(a))#123457889000
a1 = -134
print(a1)
print(type(a1))
print(id(a1))
b = 23.345
print(b)
print(type(b))
print(id(b))
b1 = -34.567
print(b1)
print(type(b1))
print(id(b1))
c = 23+56j
print(c)
print(type(c))
print(id(c))
c1= -23+567j
print(c1)
print(type(c1))
print(id(c1))
2. Sequence datatypes:
a.List
b.Tuple
c.String
""""
string : string is a collection of characters
it can be enclosed in single quotes('') or double quotes("")
"""
a = "cse"
print(type(a)) #<class "string"
print(id(a))
List : It is a collection of items/values/elements
"""
list is a collection of items/values/elements
listname = [val1,val2...]
"""
mylist = [12,23.56, 45+67j, "cse",[1,2,3]] #items/values/elements=5
print(mylist)
print(type(mylist))
print(mylist[0])#12
print(mylist[3])#cse
print(mylist[4])#[1,2,3]
#Changing the elements in a list
mylist[4]="dept"
print(mylist)
Tuple : Tuple is a collection of items/values/elements
Tuple syntax
tuplename=(val1,val2,valn)
How we can the access the elements in a tuple
Using the index
Tuple is immutable –unchangeable
"""
mytuple=(12,23.45,56+78j,"cse",(1,23,34),[12,34,56])#elements/items/values
==6
print(mytuple)
print(type(mytuple))
print(mytuple[0])
print(mytuple[2])
print(mytuple[5])
#mytuple[0]="hi"
#print(mytuple)
1.True
2.False
a = True
print(type(a))
b = False
print(type(b))
Set:
Set is a collection of items
A Set can be enclosed in flower braces{} and separated by
(,)
Setsyntax setname = {val1,val2,..valn}
myset= {12,34,45,56.89, 45+67j, "cse",(12,23,45),True}
print(myset)
print(type(myset))
#Acessing the elements in a set
#print(myset{0})
"""
Logical Operators are used to perform logical Operations
The Operators are
Logical OR--If one of the condition is True then its going to Return the
True
Logical AND-- If Both the conditions are True then its going to return the
True
Logical NOT-- It just negotiates the condition
"""
a = 23
b = 30
c = a<b and b>a #t and t -- t
print(c)#True
d = 40
e = 45
f = d>e or e>d # f or t --t
print(f)#true
a = 1
print(not(a)) #FALSE
a = 0
print(not(a)) #True
"""
Realtional Operator/Comparsion Operator
The Operators are used to compare the Values and return the Boolean
values
"""
a = int(input("enter a number: "))
b = int(input("enter a number: "))
print("The greater value", a>b)
print("The lesser value", a<b)
print("The greater than and equals too value",a>=b)
print("The lesse than and equals too value",a<=b)
print("the equals too value",a==b)
print("the not equals too value",a!=b)
"""
Membership operators are used to check the values are present
in a given sequence or not
the operators are in not in
"""
x = ["apple", "banana", "jack", "kiwi"]
print("pineapple" in x) #False
print("apple" in x)#True
print("dragon" not in x)#True
print("banana" not in x)#False
""""
identity operators are used to compare the values and return boolean
values
the operators are is / is not
"""
x = [ 1,2,3]
y = [4,5,6]
z =x
print(x is z)#True
print(x is y)#False
print(x is not y)#True
print(z is not y)#True
"""
Logical Operators are used to perform logical Operations
The Operators are
Logical OR--If one of the condition is True then its going to Return the
True
Logical AND-- If Both the conditions are True then its going to return the
True
Logical NOT-- It just negotiates the condition
"""
a = 23
b = 30
c = a<b and b>a #t and t -- t
print(c)#True
d = 40
e = 45
f = d>e or e>d # f or t --t
print(f)#true
a = 1
print(not(a)) #FALSE
a = 0
print(not(a)) #True
"""
Python conditonal statements are broadly divided into "3" Types
1.Condtional /Decision Making statements
2. Looping/Iterative Statements
3. Jumping/Transfer Statements
"""
#Decision Making Statements
"""
Decison Making statements are used to check the conditions and execute
them
The decision Making statements are:
1. if statement
2. if else statement
3. elif statement
4. Nested if statement
5. Shorthand if
6. Shorthand if else
"""
#ex:
a = 5
if a==5:
print("the if condition is executed...")
"""
if else -- when the condition in if block is failed/false
then the else block is executes
syntax: if conditon:
#statements
else:
#statements
"""
a = 10
b = 15