0% found this document useful (0 votes)
15 views

Assignment 2 - Date 16 11 23

The document contains 11 questions related to Python programming concepts like integers, floats, complex numbers, booleans, and operators. It demonstrates how to perform basic arithmetic operations and type conversions, check equality and relational operators, take user input, and make conditional checks. Example code is provided for each question to solve problems involving variables, data types, operators, and conditional statements.

Uploaded by

Avishek Jha
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)
15 views

Assignment 2 - Date 16 11 23

The document contains 11 questions related to Python programming concepts like integers, floats, complex numbers, booleans, and operators. It demonstrates how to perform basic arithmetic operations and type conversions, check equality and relational operators, take user input, and make conditional checks. Example code is provided for each question to solve problems involving variables, data types, operators, and conditional statements.

Uploaded by

Avishek Jha
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/ 5

ASSIGNMENT-1 - Colaboratory https://colab.research.google.com/drive/1BQ3e4r2mKqj2Jq2dvMfb_6...

ASSIGNMENT - 2

----------------------------
1. NAME : SUPRIYA DHARA
2. STREAM : MCA
3. SEM : 1
4. SESSION : 2023-2025
5. ROLL NO : 4
�. GROUP : X

Q1 : USE OF INTEGER

a = 10
b = 24
c = 16
d = 30
e = 2
f = 3
g = 5

w = a+b-c
x = d**c
y = f % g

print(w)
print(x)
print(y)
18
430467210000000000000000
3

Q2: USE OF FLOAT

i = 3.5
j = 1.2
print(i%j)
1.1

Q3 : USE OF COMPLEX

1. Find out the ans of c

1 of 5 22-11-2023, 21:54
ASSIGNMENT-1 - Colaboratory https://colab.research.google.com/drive/1BQ3e4r2mKqj2Jq2dvMfb_6...

2. Find out the real part of a


3. Find out the imaginary part of a

a = 1+2j
print(type(a))

b = 3 * a
print(b)

c = a*b
print(c)

print("real part of a is : ",a.real)


print("imaginary part of a is : ",a.imag)
<class 'complex'>
(3+6j)
(-9+12j)
real part of a is : 1.0
imaginary part of a is : 2.0

Q4: USE OF BOOLEAN x = 10, y = 20 �nd out the result of x>y, x<y, x<=y, x>=y

x = 10
y = 20
print(x>y)
print(x>=y)
print(x<=y)
print(x<y)
False
False
True
True

Q5: USE OF TYPE

a = 5
b = 5.8
c = 3+2j

print(type(a))
print(type(b))
print(type(c))
<class 'int'>
<class 'float'>
<class 'complex'>

2 of 5 22-11-2023, 21:54
ASSIGNMENT-1 - Colaboratory https://colab.research.google.com/drive/1BQ3e4r2mKqj2Jq2dvMfb_6...

<class 'complex'>

Q6: CONVERT ALL THE VALUES IN INTEGER a = 3.14 , b = '485' , c = '768'

1. Find out the value of c


2. convert '1011' to Decimal
3. '341' is in octal convert it in to Decimal
4. '21' is in hexadecimal it in to decimal

a = 3.14
b = '485'
c = '768'

print(int(c))
print(type(int(c)))

d = '1011'
print(int('1011',2))
print(int('341',8))
print(int('21',16))

768
<class 'int'>
11
225
33

Q7: CONVERT TO FLOAT a = 35 , b = '4.85', c = '7.68' k = 1 + j

a = 35
b ='4.85'
c = '7.68'
print(float(a))
print(float(b))
print(float(c))
35.0
4.85
7.68

Q8: CONVERT TO BOOL

a = 35

3 of 5 22-11-2023, 21:54
ASSIGNMENT-1 - Colaboratory https://colab.research.google.com/drive/1BQ3e4r2mKqj2Jq2dvMfb_6...

b = 4.2

print(bool(a))
print(bool(b))
True
True

Q9: CONVERT TO COMPLEX

a = 35
x = complex(4.85, 1.1)
y = complex(4.68,2.1)

print(a)
print(x)
print(y)
35
(4.85+1.1j)
(4.68+2.1j)

Q10: Take two numbers check whether they are equal or


not [sloved by Equal Operator]

a = int(input("Enter 1st Number : "))


b = int(input("Enter 2nd Number : "))

if(a==b):
print("Numbers are Equal")
else:
print("Numbers are Not Equal")
Enter 1st Number : 10
Enter 2nd Number : 25
Numbers are Not Equal

Q11: Take two numbers check whether the sum of number


is Greater than 5, less than 5 or Equal to 5

a = int(input("Enter 1st Number : "))


b = int(input("Enter 2nd Number : "))

4 of 5 22-11-2023, 21:54
ASSIGNMENT-1 - Colaboratory https://colab.research.google.com/drive/1BQ3e4r2mKqj2Jq2dvMfb_6...

if(a+b)>5:
print("The sum of number is Greater than 5")
elif(a+b)==5:
print("The sum of number is Equal to 5")
else:
print("The sum of number is less than 5")

Enter 1st Number : 2


Enter 2nd Number : 4
The sum of number is Greater than 5

5 of 5 22-11-2023, 21:54

You might also like