0% found this document useful (0 votes)
2 views12 pages

2nd Python Full Stack Online

The document provides a step-by-step guide on downloading Python and Microsoft Visual Studio Code IDE, followed by an introduction to Python comments, variables, and data types. It covers the creation and initialization of variables, different data types such as numbers, sequences, booleans, sets, and dictionaries, as well as operators and conditional statements in Python. The content is aimed at beginners learning Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

2nd Python Full Stack Online

The document provides a step-by-step guide on downloading Python and Microsoft Visual Studio Code IDE, followed by an introduction to Python comments, variables, and data types. It covers the creation and initialization of variables, different data types such as numbers, sequences, booleans, sets, and dictionaries, as well as operators and conditional statements in Python. The content is aimed at beginners learning Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Download of a python

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

Step5 : After downloading the python open the command prompt


Type as python –version it should show the version that you have downloaded

Download of Microsoft visual studio Code IDE(Integrated Developed Environment)


Step1 : Open the chrome and give a suggestion as Download Visual Studio code for windows
It was navigated into other page and 1st link on that page so your navigated into visual studio
code page where u can download the vscode
Step2 : Or else Use the link to download
https://code.visualstudio.com/download

Day-2 Python Comments / Variables/ Data Types

1.​ Python Comments:


Which provide additional information about the coding
There are like “2” Types:
1.​ Single line comments : which can represented by using hashtag(#)
2.​ Multiline comments : This can be represented by using “”””

""""
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
"""

#A--- > Variable


#A=----->Variable Intialisation
#A=123----->Variable Declaration/Variable Creation
A = "hello" #Good variable
print(A)

A123 = 123 # Good variable


print(A123)

Abvvv = "cse" # Good variable


print(Abvvv)

a1= 'hello' #Good variable


print(a1)

abbccc = "1233"#Good variable

print(abbccc)

_123= "hello"
print(_123)

_A= 123
print(_A)

#123 = 123--bad

#$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.Integer – all the positive and negative whole numbers


from o to n and o to -n
Integer – which can represented as int()
B. Float — all the decimal and fractional values i.e o to
n.n and o to -n.n
Float – which can represented as float()
c.Complex—which complex datatype can be represented by
Real and imaginary values
This can be in the format “a+bj”
Complex– which can be represented as complex()

type()-- which tells about the type of data

“Note”:where all the python datatypes are located?


Simple they were into a class
id() – which tells about the address location of a
value..

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

It can be represented in [] and separated by (,)


List values are called as CSV Values(Comma Separated
Values)

Syntax: list name = [val1,val2,...valn]

Mylist = [12,23.45, 456+7j, “cse”, [1,2,3]]

List is mutable item..


We can change the list elements

How we can change the list elements


1.using the index
Index is used to access the elements

Indexing always starts with “0”


Ends with n-1

"""
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)

3. Boolean : In this we have two categories

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})

Dictionary : A dictionary is a collection of key value


pairs
It can be represented as {}
Syntax = mydict={key1,valu1, kwy2,val2,key3,val3}
Key is always unique
Dictionary is mutable

mydictionary = {1:"cse", 2:2345,"dept":"cse"}


print(mydictionary)
print(type(mydictionary))
#dictionary is mutable
mydictionary[1]="ml"
print(mydictionary)
"""
Operators

A Operator is a special symbol which is used to perform an operation on


operands
c = a+b "+"
c , a, b is operands
1. Arthimetic Operator
2. Relational/Comparsion Operator
3.Assignment Operator
4.Logical Operator
5.Bitwise Operator
6.Identity Operator
7.Memebership Operator
"""
#Arthimetic Operator : An Arthimetic Operators is used to perform
Arthimetic/Mathematical Operations
"""
They are + - * / // % **
"""
a=int(input("enter a number: "))
b = int(input("enter a number: "))
print("The addition of",a+b)
print("The subtraction of ",a-b)
print("The multiplication of",a*b)
print("The division of",a/b)#
print("The floor division of",a//b)#Which returns the integral part of
quotient
print("The modular division of",a%b)#Which returns the remainder
print("The power of",a**b)

"""
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

The operators are >, <, >=,<=, ==,!=

"""
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

"""

"""if condition is executed when the condtion is true


if is executed when the block of code is true
syntax : if condition:
#statements
In order to represent a block of code we are using the indentation
"""

#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

if a==b and b>a: # F and T --F


print("the if block is executed...")
else:
print("the else block is executed...")

You might also like