home
/
courses
/
python-tutorial-for-beginners-2-integers-and-floats-working-with-numeric-data
Python Tutorial for Beginners - 2. Integers and Floats - Working with Numeric Data
Run Code 1 in Python
Run Code 2 in Python
Run Code 3 in Python
Run Code 4 in Python
Run Code 5 in Python
Run Code 6 in Python
Run Code 7 in Python
Run Code 8 in Python
Run Code 9 in Python
Run Code 10 in Python
Run Code 11 in Python
Run Code 12 in Python
Run Code 13 in Python
Run Code 1 in Python
# file: 'app1.py'
# Arithmetic Operators:
# Addition: 3 + 2
# Subtraction: 3 - 2
# Multiplication: 3 * 2
# Division: 3 / 2
# Floor Division: 3 // 2
# Exponent: 3 ** 2
# Modulus: 3 % 2
num = 3
print ( type ( num ))
Run Code 2 in Python
# file: 'app2.py'
num = 3.14
print ( type ( num ))
Run Code 3 in Python
# file: 'app3.py'
print ( 3 + 2 )
print ( 3 - 2 )
print ( 3 * 2 )
print ( 3 / 2 )
print ( 3 // 2 )
print ( 3 ** 2 )
Run Code 4 in Python
# file: 'app4.py'
print ( 2 % 2 )
print ( 3 % 2 )
print ( 4 % 2 )
print ( 5 % 2 )
Run Code 5 in Python
# file: 'app5.py'
print ( 3 * 2 + 1 )
print ( 3 * ( 2 + 1 ))
Run Code 6 in Python
# file: 'app6.py'
num = 1
num = num + 1
print ( num )
Run Code 7 in Python
# file: 'app7.py'
num = 1
num += 1
print ( num )
Run Code 8 in Python
# file: 'app8.py'
num = 1
num += 10
print ( num )
Run Code 9 in Python
# file: 'app9.py'
num = 1
num *= 10
print ( num )
Run Code 10 in Python
# file: 'app10.py'
print ( abs ( - 3 ))
print ( round ( 3.75 ))
print ( round ( 3.75 , 1 ))
Run Code 11 in Python
# file: 'app11.py'
# Comparisons:
# Equal: 3 == 2
# Not Equal: 3 != 2
# Greater Than: 3 > 2
# Less Than: 3 < 2
# Greater or Equal: 3 >= 2
# Less or Equal: 3 <= 2
num_1 = 3
num_2 = 2
print ( num_1 == num_2 )
print ( num_1 != num_2 )
print ( num_1 < num_2 )
print ( num_1 > num_2 )
print ( num_1 <= num_2 )
print ( num_1 >= num_2 )
Run Code 12 in Python
# file: 'app12.py'
num_1 = '100'
num_2 = '200'
print ( num_1 + num_2 )
Run Code 13 in Python
# file: 'app13.py'
num_1 = '100'
num_2 = '200'
num_1 = int ( num_1 )
num_2 = int ( num_2 )
print ( num_1 + num_2 )
Comments 💬
© 2018 - 2022 Milovan Tomašević. All rights reserved.
Impress
|
Cookies Policy
Powered by MT v9.1.4