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 acfb680

Browse files
Basic integers and float added
1 parent d3aea80 commit acfb680

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.vscode
2-
learn
2+
learn
3+
.gitignore

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

‎__pycache__/numbers.cpython-36.pyc‎

592 Bytes
Binary file not shown.

‎numbers.py‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# NUMBERS
2+
3+
num_1 = 3
4+
num_2 = 3.14
5+
6+
print(type(num_1)) # Type Int
7+
print(type(num_2)) # Type Float
8+
9+
10+
# ARITHMETIC
11+
12+
# Arithmetic Operators:
13+
# Addition: 3 + 2
14+
# Subtraction: 3 - 2
15+
# Multiplication: 3 * 2
16+
# Division: 3 / 2
17+
# Floor Division: 3 // 2 # Removes the decimal part
18+
# Exponent: 3 ** 2
19+
# Modulus: 3 % 2
20+
21+
# Try
22+
print(3 % 2)
23+
24+
# Arithmetic variables
25+
num = 1
26+
num = num + 1
27+
print(num) # 2
28+
29+
num = 1
30+
num += 2
31+
print(num) # 3
32+
33+
print('\n')
34+
35+
# Absolute value
36+
print(abs(-10)) # 3
37+
38+
# Rounding
39+
print(round(3.75))
40+
print(round(3.45))
41+
print(round(3.75, 1))
42+
print(round(3.768, 2))
43+
44+
print('\n')
45+
46+
# COMPARISONS:
47+
# Equal: 3 == 2
48+
# Not Equal 3 != 2
49+
# Greater Than: 3 > 2
50+
# Less Than: 3 < 2
51+
# Grater or Equal: 3 >= 2
52+
# Less or Equal: 3 <= 2
53+
54+
num_1 = 3
55+
num_2 = 2
56+
57+
print(num_1 == num_2) # Returns and prints a boolean
58+
print(num_1 != num_2)
59+
print(num_1 <= num_2)
60+
61+
print('\n')
62+
63+
64+
# STRINGS AND NUMBERS (CASTING)
65+
num_1 = '100' # Those are strings!
66+
num_2 = '200'
67+
68+
# We want to add these two numbers, but those are strings!
69+
print(num_1 + num_2) # This will chain the two strings
70+
71+
num_1 = int(num_1) # This is a 'cast'
72+
num_2 = int(num_2) # Now these are integers!
73+
74+
print(num_1 + num_2)
75+
76+
77+
# --------------------> <-------------------- #

0 commit comments

Comments
(0)

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