-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasics.py
More file actions
51 lines (42 loc) · 785 Bytes
/
basics.py
File metadata and controls
51 lines (42 loc) · 785 Bytes
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
# This is a comment.
x = 4 # x is of type int
x = "Sally" # x is now of type str
y = "Hello, World!"
# case sensitive
a = 4
A = "Sally"
# A will not overwrite a
"""
This is hack to comment
on
multiple
lines
"""
print(x)
print(y)
# casting
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
print(x) # <type 'str'>
print(y) # <type 'int'>
print(z) # <type 'float'>
print(type(x))
print(type(y))
print(type(z))
# multiple variables, multiple values
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
# one value, multiple variables
x = y = z = "Orange"
print(x)
print(y)
print(z)
# unpacking variables
fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)