-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path09_Python Variables.py
More file actions
57 lines (44 loc) · 1.35 KB
/
09_Python Variables.py
File metadata and controls
57 lines (44 loc) · 1.35 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# >>>>>>>>>>>>>>... https://www.w3schools.com/python/python_variables.asp <<<<<<<<<<<<<<<
# clik the and check the whole python variable examples and make that !!
# Variables
# Variables are containers for storing data values.
# Creating Variables
# Python has no command for declaring a variable.
# A variable is created the moment you first assign a value to it.
# Example
x = 5
y = "Amit"
print(x)
print(y)
# Variables do not need to be declared with any particular type, and can even change type after they have been set.
# Example
x = 4 # x is of type int
x = "Siya" # x is now of type str
print(x)
# Casting
# If you want to specify the data type of a variable, this can be done with casting.
# Example
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0
# Get the Type
# You can get the data type of a variable with the type() function.
# Example
x = 5
y = "Amit"
print(type(x))
print(type(y))
# You will learn more about data types and casting later in this tutorial.
# Single or Double Quotes?
# String variables can be declared either by using single or double quotes:
# Example
x = "Motu"
# is the same as
x = 'Motu'
# Case-Sensitive
# Variable names are case-sensitive.
# Example
# This will create two variables:
a = 4
A = "Amit"
#A will not overwrite a