Skip to content

Commit 23dd2bb

Browse files
authored
Add files via upload
1 parent 3fdf198 commit 23dd2bb

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

Built-In Basic Data Types.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
# coding: utf-8
3+
4+
# In[1]:
5+
6+
7+
#Numeric Data Types
8+
# Integer
9+
10+
x=3
11+
y=x
12+
13+
print("Data type of x: ",type(x),'\n')
14+
print("Data type of y: ",type(y),'\n')
15+
16+
17+
# In[2]:
18+
19+
20+
#Numeric Data Types
21+
# float
22+
23+
x=3.5
24+
y=x
25+
print("Data type of x: ",type(x),'\n')
26+
print("Data type of y: ",type(y),'\n')
27+
28+
29+
# In[3]:
30+
31+
32+
#Numeric Data Types
33+
# complex numbers
34+
35+
x=5
36+
y=3
37+
38+
aComplex= complex(5,3)
39+
print ("aComplex is a complex number: ", aComplex, "\n")
40+
print("Data type of aComplex: ",type(aComplex),'\n')
41+
42+
43+
# In[4]:
44+
45+
46+
#Logical Data Types
47+
# Boolean Values: bool
48+
49+
boolVar = True
50+
print("boolVar is a boolean variable: ",boolVar,"\n")
51+
print("Data type of boolVar: ",type(boolVar),'\n')
52+
53+
54+
# In[6]:
55+
56+
57+
# Any values that are not 0 or null can be used as True boolean value in Python
58+
59+
boolVar = 5
60+
61+
if(boolVar):
62+
print("boolVar is a boolean variable: ",boolVar,"\n")
63+
print("Data type of boolVar: ", type(boolVar), '\n')
64+
65+
66+
# In[7]:
67+
68+
69+
boolVar = False
70+
71+
print("boolVar is a boolean variable: ",boolVar,"\n")
72+
print("Data type of boolVar: ",type(boolVar),'\n')
73+
74+
75+
# In[8]:
76+
77+
78+
boolVar = 0
79+
80+
if(boolVar):
81+
print("boolVar is a boolean variable: ",boolVar,"\n")
82+
print("Data type of boolVar: ", type(boolVar), '\n')
83+
84+
85+
# as the value above is 0, nothing was executed and printed
86+
87+
# In[9]:
88+
89+
90+
# Character Data Types
91+
92+
aChar = 'a'
93+
print("aChar is a String Variable, NOT a Character variable: ", aChar, "\n")
94+
print("Data type of aChar: ", type(aChar),'\n')
95+

0 commit comments

Comments
 (0)