Subscribe this Blog

Wikipedia

Search results

Notifications and New Posts!

Thursday, October 22, 2020

Google Meet Session - 22th Oct. 2020 ADVANCED PROGRAMMING CONCEPTS - Python (TY A and B)

 ADVANCED PROGRAMMING CONCEPTS - Python

Thursday, 22 October13:30 – 15:30
Weekly on Thursday, until 30 Nov 2020
Join with Google Meet
https://meet.google.com/hid-dmnv-qxw
Join by phone
Description:Subject : ADVANCED PROGRAMMING CONCEPTS - Python To solve assignments Please join Google Classroom. Invitation of Google Classroom has been sent to your official email id. Please accept the google classroom invitation through official email id. Or directly by entering Class code of Google Classroom also you can join Google Class room to solve assignments. Class code of Google Classroom : 3ojdsjm With kind regards, SD Bhosale
  1. 10 minutes before
Organiser: Sachin Bhosale

Note: Due to network issue: Attendance and Recording of Video could not get captured. Python Programs are shared here:

# Python Operators
# Operators are used to perform operations on variables and values.
#
# Python divides the operators in the following groups:
#
# Arithmetic operators
# Assignment operators
# Comparison operators
# Logical operators
# Identity operators
# Membership operators
# Bitwise operators

# Python Arithmetic Operators
# Arithmetic operators are used with numeric values
# to perform common mathematical operations:

# + Addition x + y

x = 5
y = 3

print("Addtion of two number=",x + y)
Output:
Addtion of two number= 8

# - Subtraction x - y

x = 5
y = 3

print(x - y)
Output:
2

# * Multiplication x * y

x = 5
y = 3

print(x * y)
Output:
15

# / Division x / y
x = 1
y = 2

print(x / y)
Output:
0.5

# % Modulus x % y

x = 11
y = 7

print(x % y)
Output:
4

# ** Exponentiation x ** y

x = 2
y = 5

print(x ** y) #same as 2*2*2*2*2
print(y**x)

Output:
32
25

# // Floor division x // y
x = 15
y = 2
# /
print(x // y)

#the floor division // rounds the result down to the nearest whole number

#end of arithmetic operators
Output:
7

# Python Assignment Operators
# Assignment operators are used to assign values to variables:

# = x = 5 x = 5

x = 5

print(x)

Output:
5

# += x += 3 x = x + 3

x = 5

x += 3

print(x)
Output:
8


# -= x -= 3 x = x - 3

x = 5

x -= 3

print(x)
Output:
2

# *= x *= 3 x = x * 3
x = 5

x *= 3

print(x)
Output:
15

# /= x /= 3 x = x / 3
x = 5

x /= 3

print(x)
Output:
1.6666666666666667 

# %= x %= 3 x = x % 3
x = 5

x%=3

print(x)

Output:
2

# //= x //= 3 x = x // 3
x = 5

x//=3

print(x)
Output:
1

# **= x **= 3 x = x ** 3
x = 5

x **= 3

print(x)


# end of python assignment operators

Output:
125

# Python Comparison Operators/Relational operators
# Comparison operators are used to compare two values:

# == Equal x == y

x = 5
y = 3

print(x == y)

# returns False because 5 is not equal to 3
Output:
False

# != Not equal x != y
x = 5
y = 3

print(x != y)

Output:
True

# > Greater than x > y

x = 5
y = 3

print(x > y)
Output:
True

# < Less than x < y

x = 5
y = 3

print(x < y)

# returns False because 5 is not less than 3

Output:
False

# >= Greater than or equal to x >= y

x = 5
y = 3

print(x >= y)

Output:
True

# <= Less than or equal to x <= y

x = 5
y = 3

print(x <= y)

Output:
False

# Python Logical Operators
#Logical operators are used to combine conditional statements:

# and Returns True if both statements are true x < 5 and  x < 10

x = 5



print(x > 3 and x < 10)
        #1 && 1  = 1

Output:
True

# or Returns True if one of the statements is true x < 5 or x < 4
x = 5


print(x < 3 or x < 4)
       # 0||0 -> 0

Output:
False

# not Reverse the result, returns False if the result is true
# not(x < 5 and x < 10)


x = 0

#print(not(x > 3 and x < 10))
    #!(1&&1) ->0

print(not (x>5) )

# ! Logical NOT
# not
Output:
True

# Python Identity Operators
# Identity operators are used to compare the objects,
# not if they are equal, but if they are actually the same object,
# with the same memory location:

# is Returns True if both variables are the same object x is y

x = ["apple", "banana"]
y = ["apple", "banana"]
z = x

# p=1;

# print(x is z)
# print(x!=z)

print(z is x)


#print(x == y)

Output:
True

#is not Returns True if both variables are not the same object


x = ["apple", "banana"]
y = ["apple", "banana"]
#z = x
z=1
x=y

print(x is not z)


#print(z is y)
#
#
# print(x != y)


#end of Identity operator

Output:
True

# Python Membership Operators
# Membership operators are used to test if a sequence is presented in an object:

#in Returns True if a sequence with the specified value is present in the object

# x = ["apple", "banana"]
# #
# print("Apple" in x)

# y=(1,2,3)
#
# print(4 in y)

s={3,2,1}

# print(type(s))
print(4 not in s)
Output:
True


x = ["apple", "banana"]

print("pineapple" not in x)
Output:
True

# Python Bitwise Operators
# Bitwise operators are used to compare (binary) numbers:

& AND Sets each bit to 1 if both bits are 1

| OR Sets each bit to 1 if one of two bits is 1

^ XOR Sets each bit to 1 if only one of two bits is 1

~ NOT Inverts all the bits

<< Zero fill left shift Shift left by pushing zeros in from the right and let the leftmost bits fall off

>> Signed right shift Shift right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off    

No comments:

Post a Comment