PYTHON pop HACK 1:

def check_number():
    try:
        number = float(input("Please enter a number: "))
        if number < 0:
            print("The number is negative.")
        else:
            print("The number is non-negative.")
    except ValueError:
        print("Invalid input! Please enter a valid number.")

check_number()
The number is non-negative.

PYTHON pop HACK 2:

def check_scores(score1, score2):
    if score1 >= 70 and score2 >= 70:
        print("The student passed both subjects.")
    else:
        print("The student did not pass both subjects.")


score1 = float(input("Enter the first score: "))
score2 = float(input("Enter the second score: "))

check_scores(score1, score2)
The student did not pass both subjects.

PYTHON pop HACK 3:

def check_vowel(char):
    vowels = 'aeiou'
    if char.lower() in vowels:
        print(f"The character '{char}' is a vowel.")
    else:
        print(f"The character '{char}' is not a vowel.")


char = input("Enter a character: ")


if len(char) == 1:
    check_vowel(char)
else:
    print("Please enter a single character.")
The character 'a' is a vowel.

PYTHON HW HACK 1:

def truth_table():
    print("A     B     not (A and B)    not A or not B")
    print("-------------------------------------------")
    
    values = [True, False]
    
    for A in values:
        for B in values:
            result1 = not (A and B)
            result2 = not A or not B  # Applying De Morgan's Law
            print(f"{A}  {B}    {result1}             {result2}")

# Calling the function to print the truth table
truth_table()
A     B     not (A and B)    not A or not B
-------------------------------------------
True  True    False             False
True  False    True             True
False  True    True             True
False  False    True             True

PYTHON HW HACK 2:

import random

def guessing_game():
    print("Welcome to the guessing game!")
    print("You need to guess if two statements are True or False.")
    
    condition1 = random.choice([True, False])
    condition2 = random.choice([True, False])
    
    print("\nIs the first condition True? (yes/no)")
    guess1 = input().strip().lower() == 'yes'
    
    print("Is the second condition True? (yes/no)")
    guess2 = input().strip().lower() == 'yes'
    
    # Using De Morgan's Law to simplify the losing condition
    if not (condition1 or condition2):  # Equivalent to `not condition1 and not condition2`
        print("Both conditions were False. You lose!")
    else:
        if guess1 == condition1 and guess2 == condition2:
            print("Congratulations! You guessed both conditions correctly!")
        else:
            print("Sorry! You guessed wrong. The correct conditions were:")
            print(f"Condition 1: {condition1}")
            print(f"Condition 2: {condition2}")

# Start the game
guessing_game()
Welcome to the guessing game!
You need to guess if two statements are True or False.

Is the first condition True? (yes/no)
Is the second condition True? (yes/no)
Both conditions were False. You lose!

PYTHON HW HACK 3:

def check_number(number):
    if number < 0:
        return "The number is negative."
    else:
        return "The number is not negative."

# Test the function
print(check_number(-10))  # Output: The number is negative.
print(check_number(5))    # Output: The number is not negative.

The number is negative.
The number is not negative.

PYTHON HW HACK 4:

def check_scores(score1, score2):
    if score1 >= 70 and score2 >= 70:
        return "Both scores are 70 or above."
    else:
        return "One or both scores are below 70."

# Test the function
print(check_scores(75, 80))  # Output: Both scores are 70 or above.
print(check_scores(60, 80))  # Output: One or both scores are below 70.

Both scores are 70 or above.
One or both scores are below 70.

PYTHON HW HACK 5:

def check_vowel(character):
    vowels = "aeiouAEIOU"
    if character in vowels:
        return f"{character} is a vowel."
    else:
        return f"{character} is not a vowel."

# Test the function
print(check_vowel('a'))  # Output: a is a vowel.
print(check_vowel('B'))  # Output: B is not a vowel.

a is a vowel.
B is not a vowel.

Javascript pop Hack 1:

function outfitPicker(temp) {
    if (temp <= 32) {
        return "It's freezing! Wear a heavy coat, gloves, and a scarf.";
    } else if (temp > 32 && temp <= 60) {
        return "It's chilly! Wear a jacket and jeans.";
    } else if (temp > 60 && temp <= 80) {
        return "It's warm! A t-shirt and shorts should be fine.";
    } else if (temp > 80) {
        return "It's hot! Wear light clothing like a tank top and shorts.";
    } else {
        return "Please enter a valid temperature.";
    }
}

// Example: Prompting the user to input the temperature
let temperature = prompt("Enter the temperature:");
console.log(outfitPicker(Number(temperature)));

Javascript pop Hack 2:

function findLargestAndSort(numbers) {
    numbers.sort((a, b) => a - b); // Sorting numbers in ascending order
    console.log(`Sorted numbers from least to greatest: ${numbers}`);
    console.log(`The largest number is: ${numbers[numbers.length - 1]}`);
}

// Example usage
let numberList = [34, 15, 88, 2, 43, 19];
findLargestAndSort(numberList);

Javascript pop HACK 3:

function checkEvenOrOdd(num) {
    if (num % 2 === 0) {
        return `${num} is even.`;
    } else {
        return `${num} is odd.`;
    }
}

// Example: Prompting the user to input a number
let number = prompt("Enter a number:");
console.log(checkEvenOrOdd(Number(number)));

JAVASCRIPT HW HACK 1:

function checkPassword(password) {
    // Check if the password is at least 10 characters long, includes both uppercase and lowercase letters,
    // has at least one number, one special character, no spaces, and no more than 3 consecutive letters.
    const hasUppercase = /[A-Z]/.test(password);
    const hasLowercase = /[a-z]/.test(password);
    const hasNumber = /\d/.test(password);
    const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
    const noSpaces = !/\s/.test(password);
    const noMoreThanThreeSameLetters = !/(.)\1{2}/.test(password); // Checks for more than 3 consecutive letters

    const isValidLength = password.length >= 10;

    // Simplifying using De Morgans Law: !(A && B && C && D) becomes !A || !B || !C || !D
    if (!isValidLength || !hasUppercase || !hasLowercase || !hasNumber || !hasSpecialChar || !noSpaces || !noMoreThanThreeSameLetters) {
        return "Password does not meet the criteria.";
    }
    return "Password is valid!";
}

// Test the function
console.log(checkPassword("MySecurePass1!")); // Should return "Password is valid!" if it meets all criteria
console.log(checkPassword("badpass")); // Should return "Password does not meet the criteria."

JAVASCRIPT HW HACK 2:

function personalityQuiz() {
    let score = 0;
    
    const questions = [
        { question: "What's your favorite color?", options: ['a. Blue', 'b. Red', 'c. Yellow'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "Do you prefer the city or the countryside?", options: ['a. City', 'b. Countryside', 'c. Both'], scoreMapping: {a: 2, b: 1, c: 3} },
        { question: "Are you more of an early bird or a night owl?", options: ['a. Early bird', 'b. Night owl', 'c. Neither'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "What type of music do you like?", options: ['a. Pop', 'b. Rock', 'c. Classical'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "Do you enjoy sports?", options: ['a. Yes', 'b. No', 'c. Sometimes'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "Are you more introverted or extroverted?", options: ['a. Introverted', 'b. Extroverted', 'c. In between'], scoreMapping: {a: 2, b: 1, c: 3} },
        { question: "Which do you prefer: books or movies?", options: ['a. Books', 'b. Movies', 'c. Both'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "What's your favorite season?", options: ['a. Winter', 'b. Summer', 'c. Fall'], scoreMapping: {a: 1, b: 2, c: 3} },
        { question: "Do you prefer dogs or cats?", options: ['a. Dogs', 'b. Cats', 'c. Neither'], scoreMapping: {a: 2, b: 1, c: 3} },
        { question: "Would you rather travel or stay home?", options: ['a. Travel', 'b. Stay home', 'c. Both'], scoreMapping: {a: 2, b: 1, c: 3} }
    ];

    questions.forEach((q, index) => {
        let answer = prompt(`${index + 1}. ${q.question}\n${q.options.join('\n')}`);
        answer = answer.toLowerCase();
        if (q.scoreMapping[answer]) {
            score += q.scoreMapping[answer];
        }
    });

    let personalityType = "";

    if (score <= 10) {
        personalityType = "You are an introvert, calm and thoughtful.";
    } else if (score <= 20) {
        personalityType = "You have a balanced personality, sometimes outgoing, sometimes reserved.";
    } else {
        personalityType = "You are an extrovert, outgoing and social!";
    }

    return personalityType;
}

// Run the quiz
console.log(personalityQuiz());