-
Notifications
You must be signed in to change notification settings - Fork 4
/
Python Variables and Data Types.py
69 lines (52 loc) · 1.31 KB
/
Python Variables and Data Types.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
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
64
65
66
67
68
69
# variable assignment
x = 7
y = 2.3
z = 'hello'
print(x, y, z) # 7 2.3 hello
print(type(x)) # <class 'int'>
print(type(y)) # <class 'float'>
print(type(z)) # <class 'str'>
# multiple assignment
x, y, z = 1, 2.3, 'hello'
print(x, y, z) # 1 2.3 hello
# python number
a = 5
print(a, "is of type", type(a))
a = 2.0
print(a, "is of type", type(a))
a = 2e22
print(a, "is of type", type(a)) # 2e+22 is of type <class 'float'>
a = 1+2j
print(a, "is complex number?", isinstance(1+2j, complex)) # (1+2j) is complex number? True
a = complex(2, 3)
print(a) # (2+3j)
a = True
print(a) # True
print(int(a)) # 1
a = False
print(a) # False
print(int(a)) # 0
### Built-in Atomic Data Types
print(2 + 3 * 4) # 14
print((2 + 3) * 4) # 20
print(2**3) # 8 ( ** works as exponential )
print(6/2) # 3.0 ( type float )
print(6//2) # 3 (type int)
print(6%2) # 0
print(7%3) # 1
print(2**100) # 1267650600228229401496703205376 (python can store big integer by default)
a = 2
b = 3
print(a+b) # 5
a = "Hello"
b = "World"
print(a + b)# HelloWorld
print(5*a) # HelloHelloHelloHelloHello
print(5==10) # False
print(10 > 5) # True
print((5 >= 1) and (5 <= 10)) # True
'''
** You are now able to solve following online-judge problems.
------------------------------------------------------------
1. http://codeforces.com/problemset/problem/1/A
'''