-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVariables.py
45 lines (29 loc) · 1.28 KB
/
Variables.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
# the following are all Variables.
first_name = "Gowtham"
print(first_name) # this print output as 'Gowtham"
# Handling Naming Errors
Sports = "Cricket" # capital 'S'
print(Sports) # lowercase 's'
# If we try to run this code, we’ll get the following error/output: NameError: name 'sport' is not defined
# storing Integer and Float Variables
num1 = 5 # storing an integer into a variable
num2 = 5.6 # storing a float into a variable
print( num1, num2) # you can print multiple items using commas
# storing a boolean into a variable
mug = True
print(mug)
# storing strings into a variable
name = "Gowtham"
number = '9394'
print(name, number) # this print 9394 next to the name
# using two variables to create another variable
output = num1 + num2
print(output) # this will print additon value of num1 value (5) from line 15 and num2 value (16) from line 16.
# adding, deleting, multiplying, dividing from a variable
output += 1
print(output) # same as saying output = output + 1
output *= num1
print(output) # same as saying output = output * num1
# defining a variable and overwriting it's value
name = "Kumar"
print(name)