Friday, December 20, 2019

money converter

def dollars_to_euros(amount):
    return amount * .9


def euro_to_dollar(amount):
    return amount * 1.11


print(dollars_to_euros(1))

print(euro_to_dollar(100))

class lesson person and car

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age


def print_person(person):
    print("My name is ",person.name, " and i am " ,person.age, " years old")

ali = Person("ali", 43)

print_person(ali)
     
sonia = Person("sonia", 8)

print_person(sonia)

mum = Person("Solmaz", 37)

print_person(mum)






class Car:
  def __init__(self,name, color):
      self.name = name
      self.color = color
 

def print_car(car):
    print("I am a ", car.color, " ", car.name, " car.")

rusty = Car("Rusty", "Gray")
mum_car = Car("Mum", "Gray")
sonia_car = Car("pinkyyyyy", "Pink")
tina_car = Car("yellowwww","yellow")

print_car(rusty)
print_car(mum_car)
print_car(sonia_car)
print_car(tina_car)

Wednesday, December 18, 2019

car registration number

import string

import random



def register_car_number():

    alphabet = list(string.ascii_uppercase)

#     ["A","B",....,"Z"]

    

    letter1 = alphabet[random.randint(0,26)]

    letter2 = alphabet[random.randint(0,26)]

    letter3 = alphabet[random.randint(0,26)]

    

    num1 = random.randint(0,9)

    num2 = random.randint(0,9)

    num3 = random.randint(0,9)

    



    month = input("Please enter the month the car is made ")

    year = input("Please enter the year the car is made ")



    car_number = letter1 + letter2 + letter3 +" " + month + " " + year + " "+ str(num1) + str(num2) + str(num3)

    print("Here is your car registeration number: ", car_number )



    

    

register_car_number()



    

Thursday, December 12, 2019

christmas whishes game

christmas_wishes = ["bicycle","teddy bear", "ball"]
scrambled_words = ["cylebi","rabe yddet","lbal"]

def play():
    for position, word in enumerate(scrambled_words):
        guess = input("Guess what is this scrambled word: "+ word)
       
        if position == 0:
            if guess == christmas_wishes[0]:
                print("Correct answer: ", guess)
            else:
                print("Sorry you were wrong")
        elif position == 1:
            if guess == christmas_wishes[1]:
                 print("Correct answer: ", guess)
            else:
                 print("Sorry you were wrong")
        else:
            if guess == christmas_wishes[2]:
                 print("Correct answer: ", guess)
            else:
                 print("Sorry you were wrong")
                     
                     
                     
                     
play()

Monday, December 9, 2019

santa post office

letters = []
def write_letter(message):
    letters.append(message)
   
   
def post_letter(letters):
    print("\nSanta got your letters and soon will bring you what you asked for\n")
    for letter in letters:
        print(letter)
       

for i in range(4):
    message = input("Please write your message for santa: ")
    write_letter(message)
   
post_letter(letters)

Friday, December 6, 2019

add numbers

def add(a,b):
    return int(a) + int(b)


num1 = input("please enter number 1 ")
num2 = input("please enter number 2 ")

answer = add(num1,num2)

print("Here is the addition of ", num1 ,"+",num2 ,"=",answer)

find number

nums = [1,2,3,4,5,6,7,8,9]

def find_num(num):
    for item in nums:
        if item == int(num):
            return num
     
    print("Could not find the number ",num)
 
 
inupt = input("what number you like to search?")
print(find_num(input))

Wednesday, December 4, 2019

This is a game Sonia made for Christmas

This is a game Sonia made for Christmas

def play_christmas():
    gifts = {}
    mumber_of_gifts = input("Santa says: How many people are in your family?")
   
    for x in range(int(mumber_of_gifts)):
        name = input("What is your name?")
        gift = input("What do you want Santa(me) to bring for?")
       
        gifts[name] = gift
   
    for name, gift in gifts.items():
        print("Santa is going to bring ",gift, " for ", name)
   
   
play_christmas()