-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariables
More file actions
95 lines (77 loc) · 2.19 KB
/
Copy pathVariables
File metadata and controls
95 lines (77 loc) · 2.19 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# variables_practice.py
# Integer variable
age = 25
# Float variable
height = 1.75
# String variable
name = "Alice"
# Boolean variable
is_student = True
# Print variables
print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Is student:", is_student)
# Update variables
age = age + 1
height = height + 0.05
name = name + " Smith"
is_student = False
print("\nUpdated values:")
print("Name:", name)
print("Age:", age)
print("Height:", height)
print("Is student:", is_student)
# Create a list variable
hobbies = ["reading", "cycling", "hiking"]
# Print list variable
print("\nHobbies:", hobbies)
# Add a new hobby
hobbies.append("painting")
# Print updated list variable
print("Updated Hobbies:", hobbies)
# Create a dictionary variable
profile = {
"name": name,
"age": age,
"height": height,
"is_student": is_student,
"hobbies": hobbies
}
# Print dictionary variable
print("\nProfile:", profile)
# Update dictionary variable
profile["age"] = profile["age"] + 1
# write a summary of the declaration and statement of variables
## Summary of Variable Declaration and Statement
# In Python, variables are declared by assigning a value to a name.
# The type of the variable is determined by the value assigned.
# Variables can be of different types such as integers, floats, strings, and booleans.
# Variables can also be updated by reassigning a new value to them.
let versionNumber = "2.0.0"; // declaration
versionNumber = "2.0.1"; // statement
# The let keyword allows us to create new variables like the const keyword.
#Math.round(10.3) is a call expression; read this as:
#apply the set of instructions for Math.round to the number 10.3.”
#If we type Math.round(10.3) then we get the result 10. So we say that Math.round(10.3) returns 10."
# Example of using Functions in JavaScript;
Math.round(4.7); // 5
// Example of using declarations in JavaScript;
#> versionNumber = "2.0.1";
'2.0.1'
> Math.round
[Function: round]
> Math.round(0.3)
0
> const roundValue = Math.round(10.3);
undefined
>
> roundValue
10
> const roundValueInString = `10.3 round to ${Math.round
(10.3)}`;
undefined
> roundValueInString
'10.3 round to 10'
> roundValueInString
'10.3 round to 10'