Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 84a4cd7

Browse files
python variables
1 parent 2bd86e9 commit 84a4cd7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
In python , variables are dynamically typed.
3+
It means their data type is determined at runtime.
4+
No need to specify their datatype like we do in c++ e.g. int x;
5+
"""
6+
7+
n = 0
8+
print('n =', n)
9+
# n = 0
10+
11+
n = "abc"
12+
print('n =', n)
13+
# n = abc
14+
15+
# Multiple assignments
16+
n, m = 0, "abc"
17+
n, m, z = 0.125, "abc", False
18+
19+
# Increment
20+
n = n + 1 # good
21+
n += 1 # good
22+
# n++ # bad; there is no such operator in python
23+
24+
# None is null (absence of value)
25+
n = 4
26+
n = None
27+
print("n =", n)
28+
# n = None

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /