forked from batuhanhangun/BIL006-Codesamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basics-4-type-casting.py
36 lines (33 loc) · 1.04 KB
/
basics-4-type-casting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Type Casting
#Casting into integer
print("==============================================================================")
print("Casting into integer")
var1 = int(3)
var2 = int(4.2)
var3 = int('5')
print(var1)
print(var2)
print(var3 + 5)
print("==============================================================================")
#Casting into float
print("==============================================================================")
print("Casting into float")
var1 = float(14)
var2 = float(32.5)
var3 = float('23')
var4 = float('45.13')
print(var1)
print(var2)
print(var3 + 5)
print(var4 + 5)
print("==============================================================================")
#Casting into string
print("==============================================================================")
print("Casting into string")
var1 = str('string')
var2 = str(-7)
var3 = str(-13.5)
print(var1 + " concatenation")
print("var2: " + var2)
print(var3 + "5")
print("==============================================================================")