Skip to content

Latest commit

 

History

History
36 lines (36 loc) · 796 Bytes

23. Unit 2 - Lesson 10.md

File metadata and controls

36 lines (36 loc) · 796 Bytes

Introduction to Numbers

Q1.

# find quotient using '/' and '//' like (a/b) and (a//b)
a=int(input("a: "))
b=int(input("b: "))
print(a,'/',b,'=',a/b)
print(a,'//',b,'=',a//b)
print(a,'%',b,'=',a%b)

Q2.

c1=complex(input("c1: "))
c2=complex(input("c2: "))
print("a1 + b2 =",c1+c2)
print("a1 - b2 =",c1-c2)
print("a1 * b2 =",c1*c2)
print("a1 / b2 =",c1/c2)

Number Type Conversion

Q1.

# Type Conversion Example
a = '62'
print("converting to int:",int(a),",data type:",type(int(a)))
print("converting to float:",float(a),",data type:",type(float(a)))
print("converting to complex:",complex(a),",data type:",type(complex(a)))

Q2.

a=int(input("x: "))
print("Decimal:",str(a)+" ")
print("Binary:",bin(a)+" ")
print("Octal:",oct(a)+" ")
print("Hexadecimal:",hex(a))