Skip to content

Instantly share code, notes, and snippets.

@rafayama
rafayama / homework12.py
Created August 12, 2024 23:03
home work 12
# Homework: Classes
# Read carefully until the end before you start solving the exercises.
# Practice the Basics
# Basic Class
# - Create an empty class HouseForSale
# - Create two instances.
# - Add number_of_rooms and price as instance attributes.
@rafayama
rafayama / homework11.py
Last active August 8, 2024 20:42
homework dictionaries
# HOMEWORK: Dictionaries
# Read carefully until the end before you start solving the exercises.
# Basic Dictionary
# Create an empty dictionary and then add a few of your friends. Make the key their email (can be fake)
# and the value their name. When you're done, create the same dictionary as a pre-populated dictionary.
friends = {}
friends['[email protected]'] = 'Bob'
friends['[email protected]'] = 'Ann'
@rafayama
rafayama / homework9.py
Created August 8, 2024 17:46
homework 9 functions
# HOMEWORK: Functions
# Read carefully until the end before you start solving the exercises.
# Basic Function
# Define a basic function that only prints Hello. Create the definition using def and the call that executes it.
def basic_function():
print("Hello")
# ----------------------------------------------------------------------------------------------------------------------
# Basic Function with Parameters
@rafayama
rafayama / homework8.py
Created August 6, 2024 16:00
lesson 8 homework
# Homework Lesson 8 - Workshop - Homework
# READ CAREFULLY THE EXERCISE DESCRIPTION AND SOLVE IT RIGHT AFTER IT
# Challenge 1
# Two Lowest Elements
#
# Your task is to write a program that takes a list of numbers and finds
# the two smallest numbers in it. The two smallest numbers can be equal to
# each other or different.
@rafayama
rafayama / homework7.py
Created August 6, 2024 13:34
Python loops and lists homework
# Homework: Loops
# 🔥Read carefully until the end before you start solving the exercises🔥
# Practice the Basics 💪🏻
# You can uncomment or type the necessary code on each task
# ---------------------------------------------------------------------
# Task 1. Create a basic for loop
@rafayama
rafayama / homework6.py
Created July 29, 2024 21:35
homework 6 py
# Homework: Lists
🔥 **Read carefully until the end before you start solving the exercises.** 🔥
## Practice the Basics 💪🏻
### Empty, Pre-populated, and Lists within Lists
Create three lists:
@rafayama
rafayama / homework5.py
Created July 29, 2024 20:31
lesson 5 homework py
# Homework Lesson 5 - Workshop - Homework
# READ CAREFULLY THE EXERCISE DESCRIPTION AND SOLVE IT RIGHT AFTER IT
# Challenge 1
# Make a number Positive
#
# Create a variable called my_number and set it to any integer value.
# Write code to make the number positive if it's negative, and keep it
# as is if it's already positive or zero.
@rafayama
rafayama / homework.py
Last active July 24, 2024 14:37
codewars homework challenges
#Multiply
def multiply(a, b):
return a * b
#Convert num to string
def number_to_string(num):
return str(num)
#Reverse string
def solution(str):
@rafayama
rafayama / homework.py
Created July 23, 2024 18:27
Python conditionals homework
# Homework Lesson 4 - Conditionals
# READ CAREFULLY THE EXERCISE DESCRIPTION AND SOLVE IT RIGHT AFTER IT
# ---------------------------------------------------------------------
# Exercise 1: Temperature Classification
# You're developing a weather application. Write a program that takes
# a temperature in Fahrenheit as input. If the temperature is above
# 85°F, print "Hot day ahead!".
temperature = int(input("Enter the temperature in Fahrenheit: "))
@rafayama
rafayama / homework.py
Last active July 18, 2024 21:36
python homework 3
# Homework Lesson 2 - Strings
# READ CAREFULLY THE EXERCISE DESCRIPTION AND SOLVE IT RIGHT AFTER IT
# ---------------------------------------------------------------------
# Exercise 1: Personalized Greeting
# Write a program that takes a user's name as input
# and then greets them using an f-string: "Hello, [name]!"
#
# Example Input: "Alice"