-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay2.py
More file actions
71 lines (44 loc) · 1.16 KB
/
Day2.py
File metadata and controls
71 lines (44 loc) · 1.16 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ---------------------------------------------------
# Author : Benjamin Kataliko Viranga
# Community : Stunt Business
# Community website : www.stuntbusiness.com
#
# 30 Days - Q&A Python Basic
# Day 2 : 23-05-2020
# Day 2 | IG : https://www.instagram.com/benjivrik/
# Subject : Data Type
#----------------------------------------------------
# what would be the output of this program ?
'''
This is also a comment.
The function type(x) return the data type of the element x.
We can have dict, str, int , float, list, tuple, complex
Google and search by yourself as well | I may be missing something
here.
Ex: type('hhah') will output <class 'str'>
Let's focus on these data types : Integer , Float, String, complex
'''
#variables
x = 'a'
y = 1
z = 2.5
w = 1+2j
print("----> first")
print(x) #line1
print(y) #line2
print(z) #line3
print(w) #line4
print("----> second")
print(type(x)) #line5
print(type(y)) #line6
print(type(z)) #line7
print(type(w)) #line8
print("----> third")
x = '5'
y = 1
z = 2.5+0j
w = 1+2j
print(type(int(x))) #line9
print(type(str(y))) #line10
print(type(z)) #line11
print(type(str(w))) #line12