-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02variables-data-types.py
More file actions
33 lines (27 loc) · 1.02 KB
/
02variables-data-types.py
File metadata and controls
33 lines (27 loc) · 1.02 KB
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
'''
Variables:
- Variables in Python are used to store data values.
- A variable is created the moment you first assign a value to it.
- Python is a dynamically typed language, which means you don't need to declare the type of a variable when you create one.
- The type is inferred from the value you assign to the variable. For example:
x = 5 # x is of type integer
y = "Hello" # y is of type text (aka string)
Variables can change type after they have been set. For example:
x = 4 # x is initially an integer
x = "Four" # x is now a string
Python variable names are case-sensitive and can contain letters, numbers, and underscores, but they must start with a letter or an underscore.
For eg:
lx = 5 # correct
_x = 10 #correct
3x = 15 # incorrect variable name 3x, must start with a letter
'''
number=5
name = "Rahul"
price = 3.2
go_to_movie = True
#3incorrect_variable_name : uncomment this line and run the program again
#it will show you an error message
print(number)
print(name)
print(price)
print(go_to_movie)