Helper text

Back to articles
Series: WebDev 101 Part 4

html_content = """

 

    <head>

        <title>My Page</title>

     </head>

     <body>

         <h1>Hello, World!</h1>

         <p>This HTML file was created using Python.</p>

     </body>

</html>"""

with open("index.html", "w", encoding="utf-8") as file:

    file.write(html_content)

    print("HTML file saved successfully!")

 

----------

 

def htmlBoiler(headContent, bodyContent):

    return f"{  <!DOCTYPE html> <html> <head>{headContent}</head><body>{bodyContent}</body></html>"

 

----------

And some lists:

student_names = [
    "Alice",
    "Brandon",
    "Carlos",
    "Diana",
    "Ethan"
]

ages = [
    14,
    16,
    15,
    17,
    13
]

temperatures = [
    21.5,
    19.8,
    23.1,
    18.7,
    20.4
]

is_present = [
    True,
    False,
    True,
    True,
    False
]

 

-----------

numbers = [8, 3, 12, 5, 9]

print(len(numbers))

print(min(numbers))

print(max(numbers))

print(sum(numbers))

print(sorted(numbers))

----------

 

student = { "name": "Alice",

                    "age": 15,

                    "grade": 10,

                    "average": 87.5,

                    "present": True

                    }

 

print(student["name"])

print(student["average"])

for key in student:

     print(key)

for value in student.values():

    print(value)

for key, value in student.items():

    print(key, ":", value)

person = {}

person['name'] = "Jeremy"