FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programmingWithPythonCode/variables/assignment.py at main · mlecjm/programmingWithPythonCode · GitHub
mlecjm
programmingWithPythonCode
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programmingWithPythonCode
/
variables
/
assignment.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (13 loc) · 750 Bytes
Breadcrumbs
programmingWithPythonCode
/
variables
/
assignment.py
Copy path
File metadata and controls
18 lines (13 loc) · 750 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# We define a variable named "int_var" and assign the int value 1 to it.
int_var = 1
# We can use the variable int_var in computations like any other value.
print(2 + int_var) # This should print 2 + int_var = 2 + 1 = 3.
# We can also use the variable in f-strings.
print(f"int_var has value {int_var}.") # prints 'int_var has value 1.'
# We can also change the value of the variable.
int_var = (3 * int_var) + 1 # int_var = (3 * 1) + 1 = 4
print(f"int_var is now {int_var}.") # prints 'int_var is now 4.'
float_var = 3.5 # Ofcourse we can also use floating point numbers.
print(f"float_var has value {float_var}.") # 'float_var has value 3.5.'
new_var = float_var * int_var # new_var = 3.5 * 4 = 14.0 <- a float!
print(f"{new_var = }.")
Back
|
FazBrowse Home
|
New Git URL