Skip to content

Commit 8bacccc

Browse files
RezwanRezwan
Rezwan
authored and
Rezwan
committed
1. Introduction
1 parent 6eb699b commit 8bacccc

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Python Variables and Data Types.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# variable assignment
2+
x = 7
3+
y = 2.3
4+
z = 'hello'
5+
print(x, y, z) # 7 2.3 hello
6+
7+
print(type(x)) # <class 'int'>
8+
print(type(y)) # <class 'float'>
9+
print(type(z)) # <class 'str'>
10+
11+
12+
# multiple assignment
13+
x, y, z = 1, 2.3, 'hello'
14+
print(x, y, z) # 1 2.3 hello
15+
16+
# python number
17+
a = 5
18+
print(a, "is of type", type(a))
19+
20+
a = 2.0
21+
print(a, "is of type", type(a))
22+
23+
a = 2e22
24+
print(a, "is of type", type(a)) # 2e+22 is of type <class 'float'>
25+
26+
a = 1+2j
27+
print(a, "is complex number?", isinstance(1+2j, complex)) # (1+2j) is complex number? True
28+
29+
a = complex(2, 3)
30+
print(a) # (2+3j)
31+
32+
a = True
33+
print(a) # True
34+
print(int(a)) # 1
35+
36+
a = False
37+
print(a) # False
38+
print(int(a)) # 0
39+
40+
### Built-in Atomic Data Types
41+
print(2 + 3 * 4) # 14
42+
print((2 + 3) * 4) # 20
43+
print(2**3) # 8 ( ** works as exponential )
44+
print(6/2) # 3.0 ( type float )
45+
print(6//2) # 3 (type int)
46+
print(6%2) # 0
47+
print(7%3) # 1
48+
print(2**100) # 1267650600228229401496703205376 (python can store big integer by default)
49+
50+
a = 2
51+
b = 3
52+
print(a+b) # 5
53+
54+
a = "Hello"
55+
b = "World"
56+
print(a + b)# HelloWorld
57+
print(5*a) # HelloHelloHelloHelloHello
58+
59+
60+
print(5==10) # False
61+
print(10 > 5) # True
62+
print((5 >= 1) and (5 <= 10)) # True
63+

0 commit comments

Comments
 (0)