Skip to the content.

3.6 and 3.7 popcorn and hw hacks

This is a collection of Sprint 2 Hacks.

3.6 hw hack

num1 = input("enter first number: /n")
num2 = input("enter second number: /n")

if (num1 > num2):
    print(num1 + " is more than " + num2)
elif (num1 == num2):
    print(num1 + " is equal to " + num2)
else:
    print(num1 + " is less than " + num2)
5 is less than 6

3.7 hw hack 1

INPUT exam_score
INPUT attendance_percentage

    IF exam_score >= 75 THEN
        IF attendance_percentage >= 80 THEN
            PRINT "Student passes the class."
        ELSE
            PRINT "Student fails due to insufficient attendance."
    ELSE
        PRINT "Student fails due to insufficient exam score."

3.7 hw hack 2

def shipping_cost(weight, delivery_speed):
    standard_cost = 5.00
    express_cost = 10.00

    if weight <= 1:
        cost = standard_cost + 2.00
    elif weight <= 5:
        cost = standard_cost + 5.00
    else:
        cost = standard_cost + 10.00

    if delivery_speed.lower() == "express":
        cost += 5.00

    return cost

package_weight = float(input("Enter the weight of the package (in lbs): "))
delivery_speed = input("Choose delivery speed (standard or express): ")

shipping_cost = shipping_cost(package_weight, delivery_speed)
print(f"The shipping cost is: ${shipping_cost:.2f}")

The shipping cost is: $15.00

3.7 Hw hack 3

age = int(input("Enter your age: "))
student_status = input("Are you a student? (yes or no): ")

def calculate_ticket_price(age, is_student):
    if age < 12:
        price = 10.00
    elif age < 65:
        price = 20.00
    else:
        price = 15.00

    if is_student:
        price *= 0.75
    return price

is_student = student_status == "yes"

ticket_price = calculate_ticket_price(age, is_student)
print(f"The ticket price is: ${ticket_price:.2f}")
The ticket price is: $16.00

3.7 challenge hack

side1 = float(input("Enter the length of the first side (positive number): "))
side2 = float(input("Enter the length of the second side (positive number): "))
side3 = float(input("Enter the length of the third side (positive number): "))

def classify_triangle(side1, side2, side3):
    if side1 + side2 > side3 and side1 + side3 > side2 and side2 + side3 > side1:
        if side1 == side2 == side3:
            return "Equilateral Triangle"
        elif side1 == side2 or side1 == side3 or side2 == side3:
            return "Isosceles Triangle"
        else:
            return "Scalene Triangle"
    else:
        return "The sides do not form a valid triangle."
    
triangle_type = classify_triangle(side1, side2, side3)
print(triangle_type)
Scalene Triangle