0% found this document useful (0 votes)
22 views6 pages

PyAjinkya23 24

Uploaded by

ajinkya jagtap
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)
22 views6 pages

PyAjinkya23 24

Uploaded by

ajinkya jagtap
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/ 6

Name: Date:

Class: MCA-I Roll No.:

Subject:

Experiment No: 1

Title: Program to demonstrate basic data type & Operators in python

Theory:

Program:

a) Arithmetic Operators

# Arithmetic operators

num1=int(input("Enter a number 1:"))

num2=int(input("Enter a number 2:"))

Add=num1+num2 # Addition Operator

print("Addition:",Add)

sub=num1-num2 #Substraction Operator

print("Substraction:",sub)

Mul=num1*num2 #Multiplication Operator

print("Multiplication:",Mul)

Div1=num1/num2 # Division Operator

print("Division:",Div1)

Mod=num1%num2 #Modulus Operator

print("Modulus:",Mod)

Div2=num1//num2 #Division Operator


Faculty Of MCA
print("Division:",Div2)

P=num1**num2 #Power

print("Power:",P)

Output:

Enter a number 1:20


Enter a number 2:10
Addition: 30
Substraction: 10
Multiplication: 200
Division: 2.0
Modulus: 0
Division: 2
Power: 10240000000000

Program:

b) Assignment Operator:

# assigning 20 to x

x=20

# assigning 5 to y

y=5

# assign the sum of x and y to x

x+=y #x=x+y

print("Sum of x+y :",x)

Output :

Sum of x+y : 25

Faculty Of MCA
Program:

c) Comparison Operators:

a=int(input("Enter a number 1:"))

b=int(input("Enter a number 2:"))

# equal to operator
print("a == b =", a == b)

# not equal to operator


print("a != b =", a != b)

# greater than operator


print("a > b =", a > b)

# less than operator


print("a < b =", a < b)

# greater than or equal to operator


print("a >= b =", a >= b)

# less than or equal to operator


print("a <= b =", a <= b)

Output:
Enter a number 1:18
Enter a number 2:13
a == b = False
a != b = True
a > b = True
a < b = False
a >= b = True
a <= b = False

Faculty Of MCA
Program:

d) Logical Operators:

a=int(input("Enter a number 1:"))

b=int(input("Enter a number 2:"))

# logical and
print(a==b and a>=b)

# logical or
print(a==b or a>=b)

Output:

Enter a number 1:3


Enter a number 2:2
False
True

Program:

e) Identify Operators:

x1 = 18
y1 = 13
x2 = 'Ajinkya'
y2 = 'Ajinkya'

Faculty Of MCA
print(x1 is not y1) # is not operator

print(x2 is y2) # is operator

Output:
True
True

Program:

f) Membership Operators:

a='Hello world'

# in operator
print('H' in a)

# not in operator
print('hello' not in a)

Output:

True
True

Conclusion:

Faculty Of MCA
Question/ Answers:

Faculty Of MCA

You might also like