Quick actions

cmd+k|ctrl+k

Navigation

Languages

PythonBasics0000

Snippet info

Language

Python

Visibility

public

Author

masterhun

Created

2023-08-18T18:34:05.979705Z

Updated

2023-08-18T18:36:56.91516Z



print("Hello World!")

print()

# This is a comment. 

# SyntaxError 
# print("This is an example of a SyntaxError."
print("This is NOT an example of a SyntaxError.")

print()

# TypeError 
# print("5" + 5)
print("This is NOT an example of a TypeError.")
print("5" + str(5))

print()

# NameError
# print(egg)
print("This is NOT an example of a NameError.")
egg = 5
print(egg)

print()

# IndentationError 
# if True:
# print("True")
print("This is NOT an example of an IndentationError.")
if True:
    print("True")

print()

# Addition
print(3 + 5)
# Output: 8

# Subtraction 
print(5-3)
# Output: 2

# Multiplication 
print(5 * 3)
# Output: 15 

# Division 
print(5/3)
# Output: 1.6666666666666667

# Floor division 
print(5//3)
# Output: 1

# Modulus, modulo, MOD, % 
print(5 % 3)
# Output: 2

# Exponentiation, power of 
print(5**3)
# Output: 125

# Precedence (order of operations, PEMDAS)
print(1+2*3/4)
# Output: 2.5
print(1-2/3*4)
# Output: -1.6666666666666665



INFO