Quick actions

cmd+k|ctrl+k

Navigation

Languages

Exercises

Snippet info

Language

Python

Visibility

public

Author

akaimal04

Created

2024-12-24T21:25:26.715871Z

Updated

2024-12-28T23:31:17.518388Z

# finding age
print("Finding Age\n---------------------")
birth_yr = input("what year were you born?")
age = 2024 - int(birth_yr)
print(f"\nyou are {age} years old")


#password checker
print("\n\nPassword Checker\n---------------------")
username = input("what's your username? ")
password = input("\nwhat's your password? ")

password_length = len(password)
hidden_password = "*" * password_length

print(f"{username}, your password, {hidden_password},  is {password_length} letters long.")


# Magician Logical Ops 
print("\n\nMagician Logical Ops\n---------------------")
is_magician = True
is_expert = False

if is_magician and is_expert:
    print("master magician")
    
elif is_magician and not is_expert:
    print("getting there")
    
elif not is_magician:
    print("need magic powers")
    
    
    
# Counter
print("\n\nCounter\n---------------------")
total = 0;
my_list = [1,2,3,4,5,6,7,8,9,10]

for num in my_list:
    total += num
    
print(f"Total is: {total}")



# GUI
print("\n\nGUI\n---------------------")
picture = [
    [0,0,0,1,0,0,0],
    [0,0,1,1,1,0,0],
    [0,1,1,1,1,1,0],
    [1,1,1,1,1,1,1],
    [0,0,0,1,0,0,0],
    [0,0,0,1,0,0,0]
    ]
    
for row in picture:
    for pixel in row:
        if pixel == 0:
            print(" ", end="")
        else:
            print("*",end="")
    print()
    
    
    
# Duplicates
print("\n\nDuplicates\n---------------------")
some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
dupe_list = []

for char in some_list:
    if some_list.count(char) > 1:
        if char not in dupe_list:
            dupe_list.append(char)
            
print(dupe_list)



# Tesla Driver
print("\n\nTesla Driver\n---------------------")
    
def checkDriverAge(age = 0):
    # age = input("What is your age?: ")
    if age < 18:
    	print("Sorry, you are too young to drive this car. Powering off")
    elif age > 18:
    	print("Powering On. Enjoy the ride!");
    elif age == 18:
    	print("Congratulations on your first year of driving. Enjoy the ride!")
    
checkDriverAge()
checkDriverAge(18)
checkDriverAge(24)


# Highest Even Number
print("\n\nHighest Even Number\n---------------------")

def highest_even(li):
    highest_even = -10000
    for number in li:
        if number % 2 == 0 and number > highest_even:
            highest_even = number
    return highest_even
    
print(highest_even([10,2,3,4,50,99,106,8,11]))
INFO