⭕️ ➜ Check out my NEW & OFFICIAL website @ cbbABC.neocities.org

# = comments = communication
# print("Hello world!") does not run
""" as comments with many lines as long as the string of text is not being assigned to a variable
multi-line
comments
"""

# Complete Commands with New Lines
    # 1. Command
    # 2. Command
        # and not
    # 1. Command 2. Command

# Relies on Indentation (Whitespace) with Continuous Commands
    # 1. this
        # 2. is
            # 3. continuous
    # 1. this
    # 1. is not
    # 1. continuous

# Order = Up to Down, Left to Right
# Order of Operations = PEMDAS
        # ()    = Parentheses
        # **    = Exponentiation
        # *     = Multiplication
        # %     = Modulus
        # /     = Division
        # +     = Addition
        # -     = Substraction
    # Comparator Operators
        # ==    = equal to
        # >=    = greater than equal to
        # <=    = less than equal to
    # Assignment Operators
        # +=    =
        # -=    =
        # *=    =
        # %=    =

# When it comes to order, computers count from 0.
    # A = 0
    # B = 1
    # C = 2

# print() Function
# prints a message onto the screen

# Variables
# print(X)                      # error
X = "Hello"
x = 2
XX = 3.1415
xx = True
print(X)                        # Hello
print(x)                        # 2
print(XX)                       # 3.1415
print(xx)                       # True

# Data Types
# String =
    # str('')
    # str("")
    # str("""
    #
    # """")
print('break\nlines')
print("\"special characters\"")

# int() = Integer
print(x)                        # 2
print(-x)                       # -2

# float() = Float
print(XX)                       # 3.1415

# bool() = Boolean
print(bool(x == 4))             # 2 is 4                    # false
print(bool(x > 4))              # 2 is more than 4          # false
print(bool(x < 4))              # 2 is less than 4          # true
print(bool(X))                  # strings are true          # true
print(bool(x))                  # numbers are true          # true
print(bool(True))                                           # true
print(bool(False))                                          # false
print(bool(None))                                           # false
print(bool(0))                                              # false
print(bool(""))                                             # false
print(bool(()))                                             # false
print(bool([]))                                             # false
print(bool({}))                                             # false

# Casting = Changing Data Type after Specifying it
print(str(x))                   # 2                         # no value, pure text
print(str(xx))                  # True                      # no value, pure text
print(int(XX))                  # 3
print(float(x))                 # 2.0
print(int(float(3.999)))        # 3                         # float value is lost

# Concatenation
print(X + " world!")            # Hello world!
print(X + " " + X + "!")        # Hello! Hello!
print(x + XX)                   # 5.1415
# print(X + x)                  # error                     # different types

# Sequences = Collections of Data
# List = []
List = ["A", "B", "C", "C"]

# [index] = Identify Elements in Lists
# Strings are Lists of Characters
print(X[1])                                 # what is in 2?             # e
print(List[0])                              # what is in 0?             # A
# also applicable to Tuples & Dictionaries

# Tuple = ()
# Ordered & Unchangeable
Tuple = ("A", "B", "C", "C")
Tuple_Single = ("A",)                       # comma in the end

# Lists & Tuples: Index of Elements
# A     first       0
# B     second      1
# C     third       2
# C     fourth      3

# Dictionaries
# Ordered after Python 3.7, Changeable, No Duplicates
Dictionary = {
    "Key": "value",
    "A": "a",
    "B": "b",
    "C": "c",
}
print(Dictionary["Key"])                                                # value

# Sets = {}
# Unordered, Unindexed, No Duplicates.
Set = {"A", "B", "C"}
print(Set)

# Functions = function(paremeter)
def function(argument, argument2):
    argument += argument2
    return argument
print(function(2, 3))                                                   # 5
#   print(function(2))                                                  # error         # must follow paremeter

# built-inX
print(X.index("l"))                 # index of "l"?                     # 2
print(X.index("o"))                 # index of "o"?                     # 4
#   print(X.index("z"))             # index of "z"?                     # error
print(X.upper())                    # turn uppercase                    # HELLO
print(X.isupper())                  # uppercase?                        # false
print(X.upper().isupper())          # turn uppercase, uppercase?        # true
print(X.replace("llo", "aven"))     # replace "llo" with "aven"         # Heaven

# len() = Output Amount of Elements
print(len(X))                       # 5
print(len(List))                    # 4
print(len(Tuple))                   # 4
print(len(Tuple_Single))            # 1
print(len(Dictionary))              # 4
print(len(Set))                     # 3

# type() = Identify Data Type
print(type(X))                      # str
print(type(x))                      # int
print(type(XX))                     # float
print(type(xx))                     # bool
print(type("True"))                 # str
print(type(True))                   # bool

# Importing
# you can access more by importing packages
from math import *

# importing math
print(abs(-x))                      # absolute number?                  # 2
print(pow(x, 3))                    # 2^3                               # 8.0
print(max(x, 3))                    # which is more?                    # 3
print(min(x, 3))                    # which is less?                    # 2
print(round(3.999))                 # round                             # 4
print(floor(3.999))                 # round to minimum                  # 3
print(ceil(3.999))                  # round to maximum                  # 4
print(sqrt(8))                      # square root                       # 2

# Classes
class MyClass():
    FF = 100
    F8 = 200
ew = MyClass()
print(ew.FF)    # 100
print(ew.F8)    # 200

# Conditional Statements
# if, elif, else
if x > 2:                                       # 2 is 2!
    print(str(x) + " is more than 2!")
elif x == 2:
    print(str(x) + " is 2!")
else:
    print(str(x) + " is less than 2!")
# if x is more than 2
# print "x is more than 2"
# else, if x is 2
# print "x is 2"
# else
# print "x is less than 2"

# while
while x < 10:
    x += 1
    print (x)
    if x == 5:
        break
# add 1 to x until x is above 10 BUT if x == 5, break
                                                # 3
                                                # 4
                                                # 5

# For Loops = Sequence Iteratation
# Lists have Items
for Items in List:
    print(Items)                                # A
                                                # B
                                                # C
                                                # C
# Strings have Character Sequences
for Characters in X:
    print(Characters)
    if Characters == "l":
        break
                                                # H
                                                # e
                                                # l
Edit
Pub: 05 Jun 2022 05:51 UTC
Edit: 20 Jun 2022 01:50 UTC
Views: 847