Making a variable and age

name: "Cindy"

age = 16
print(bool(age))

print(age<8)
True
False

Use all the variable types and print all the diffferent types of them, boolean, string, and integer.

age = 11
name = "Cindy"
fail = True

print(age, name, fail)
11 Cindy True
# changing of variables
num1 = 1
num2 = 2
num3 = 3
print(num1, num2, num3)
num2 = num3
num3 = num1
num1 = num2
num4 = num1 - num3
print(num1, num2, num3)
print(num4)
1 2 3
3 3 1
2

Data abstraction for lists and strings.. lists of characters, integers, strings, etc list is a set of items that can be anything, seperated by commas

something = ["hello", 12, "Cindy", "Aditi", "Eshika"]

print(something[3])
Aditi

Dictionaries - define multiple variables from a list

def __init__(self, name, age):
    self.name = "Cindy"
    self.age = 15
    
def myfunc(self):
    print("Hello my name is" + self.name)
    
---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

/tmp/ipykernel_10787/1462445020.py in <module>
      6     print("Hello my name is" + self.name)
      7 
----> 8 myfunc(self)


NameError: name 'self' is not defined
x = 5
print(isinstance(x, int))
print(dir(x))
#x is an integer, so it is true
True
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']
import json
string = ["hi", "idk", "hello", "help"]
json_obj = json.dumps(string)
print(json_obj)

["hi", "idk", "hello", "help"]
#HW hack - Class
class Person: 
    def __init__(self, name, age):
        self.name = name
        self.age = age
def print_people(people_list):
    for Person in people_list:
        print(f"name: {Person.name}, Age: {Person.age}")
def main():
    people = [Person("Aditi", 15), Person("Samhita", 14), Person("Eshika", 125)]
    print_people(people)

if __name__ == "__main__":
    main()
name: Aditi, Age: 15
name: Samhita, Age: 14
name: Eshika, Age: 125
def print_people(people_dict):
    for person_name, person_age in people_dict.items():
        print(f"Name: {person_name}, Age: {person_age}")

# Example usage
people = {
    "Aditi": 30,
    "Samhita": 35,
    "Eshika": 25
}

print_people(people)

Name: Aditi, Age: 30
Name: Samhita, Age: 35
Name: Eshika, Age: 25

Tangibles:

I think it was really interesting to review the concepts of variables, classes, isinstance, and ect. since these are still pretty new to me, and it was a good idea to go more in-depth about them.