Are You a Beginner Programmer? Build a Strong Foundation with These Projects

image from Unsplash


def add(x, y):
return x + y

def subtract(x, y):
return x - y

def multiply(x, y):
return x * y

def divide(x, y):
return x / y

print("Select operation.")

while True:
choice = input("Enter choice(1/2/3/4): ")

Guess The Number

import random

num = random.randint(1, 100)
guess = None

while guess != num:
guess = input("guess a number between 1 and 100: ")
guess = int(guess)

if guess == num:
print("congratulations! you won!")
print("Wrong Guess! try again!")

Sorting Algorithm

employees = [
{'Name': 'ABC', 'age': 22, 'salary': 100000},
{'Name': 'DEF', 'age': 40, 'salary': 80000},
{'Name': 'GHI', 'age': 37, 'salary': 13000},
{'Name': 'JKL', 'age': 28, 'salary': 150000},

def get_name(employee):
return employee.get('Name')

def get_age(employee):
return employee.get('age')

def get_salary(employee):
return employee.get('salary')
employees.sort(key=get_name)print(employees, end='\n\n')
print(employees, end='\n\n')
employees.sort(key=get_salary, reverse=True)
print(employees, end='\n\n')



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store