Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

day1 solved assignments

The document contains a series of Python programming examples demonstrating various concepts such as printing messages, summing numbers, using operators (exponentiation, floor division, identity, and bitwise), and the use of 'in' and 'not in' operators. Each example includes code snippets that illustrate the functionality of these concepts. It serves as a practical guide for beginners to understand basic Python programming.

Uploaded by

mail2dr.vikash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

day1 solved assignments

The document contains a series of Python programming examples demonstrating various concepts such as printing messages, summing numbers, using operators (exponentiation, floor division, identity, and bitwise), and the use of 'in' and 'not in' operators. Each example includes code snippets that illustrate the functionality of these concepts. It serves as a practical guide for beginners to understand basic Python programming.

Uploaded by

mail2dr.vikash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Ex Write a program to print message

str = "This is Python Language "


str1 = 'Python '
print (str)
Ex Write a program of sum of two number
a = 34
b = 34
sum = a+b
print(sum)
print("Sum is ", sum)
print("Sum is " + str(sum))
Ex Write a program of sum of two number
print("Enter fisrt number ")
a = int(input())
print("Enter second number")
b = int(input())
sum = a+b
print(sum)
Ex Write a program demonstrate ** and //
print(2**3)
print(5.86/2)
print(5.86//2)
Ex Demo of identity operator
x =23
y =x
z= 23.0
print(x is y)
print(x is z)
Ex Demo is” is” and ==
x = ["apple", "banana"]
y = ["apple", "banana"]
z=x

print(x is z) # returns True because z is the same object as x

print(x is y)

# returns False because x is not the same object as y, even if they have thew same content

print(x == y)

# to demonstrate the difference betweeen "is" and "==": this comparison returns True because x
is equal to y
EX Demo of “in” operator
x = ["apple", "banana"]

print("banana" in x)

# returns True because a sequence with the value "banana" is in the list
Ex Demo of “not in” operator

x = ["apple", "banana"]

print("pineapple" not in x)

# returns True because a sequence with the value "pineapple" is not in the list

Ex Demo of bitwise operator


a =5
b= 10
print("a & b ", a&b)
print("a | b ", a|b)
print("a ^b", a^b)
print("Compliment ",~a)
print("Shift left << ",a<<1)
print("shift right",b>>1)

You might also like