├── README.md ├── _02_FirstStepsLab ├── Hello-Softuni.py ├── GreetingsByName.py ├── RectangleArea.py ├── InchesToSantimeters.py ├── PetShop.py ├── ProjectCreation.py ├── Numbers1-10.py ├── ConcatenateData.py ├── YardGreening.py └── main.py ├── _07_ForLoop_lab ├── NumbersFrom1to100.py ├── ReverseOrder_4.py ├── CharacterSequence.py ├── Numbers1to100stepBy3.py ├── EvenPowersOfNumberTwo_3.py ├── SumNumbers.py ├── VowelsSum.py ├── Number_Sequence_8.py ├── Left_and_Right_SUM_9.py └── Odd_Even_sum_10.py ├── _02_FirstStepsExsercise ├── USDtoBGN.py ├── RadiansToDegrees.py ├── VocationBookList.py - Shortcut.lnk ├── BasketballEquipment.py ├── DepositCalculator.py ├── FishTank.py ├── FoodDelivery.py ├── SuppliesForSchool.py └── Repainting.py ├── _11_Nested-Loops-Lab ├── 01_clock.py ├── 02_multiplication_table.py ├── 03_combinations.py ├── 05_travelling.py ├── 06_building.py ├── 04_sum_of_two_numbers.py └── 07_cinema_tickets.py ├── _03_ConditionalStatementsLab ├── ExcellentResult.py ├── EvenOrOdd.py ├── GreaterNumber.py ├── PasswordGues.py ├── Number100to200.py ├── SpeedInfo.py └── AreaOfFigure.py ├── _08_For_Loop_Exercise ├── Numbers_ending_in_Seven_1.py ├── Salary_5.py ├── Half_sum_element_2.py ├── Oscars_6.py ├── Clever_lily_4.py ├── Tennis_Ranklist_8.py ├── Histogram_3.py └── Trekking_mania_7.py ├── _09_While-Loop-Lab ├── 04_sequence_2k+1.py ├── 01_read_text.py ├── 03_sum_numbers.py ├── 02_password.py ├── 07_min_number.py ├── 06_max_number.py ├── 08_graduation.py ├── 05_account_balance.py ├── 09_graduation_pt2.py └── 10_moving.py ├── _05_ConditionalStatementsAdvanced_Lab ├── NumberInRange.py ├── InvalidNumber.py ├── AnimalType.py ├── CinemaTicket.py ├── WeekendOrWorkingDay.py ├── PersonalTitles.py ├── FruitOrVegetable.py ├── WorkingHours.py ├── DayOfWeek.py ├── SmallShop.py ├── FruitShop.py └── TradeComissions.py ├── _06_ConditionalStatementsExercise ├── Cinema.py ├── HotelRoom.py ├── SkiTrip.py ├── Journey.py ├── SummerOutfit.py ├── FishingBoat.py ├── NewHouse.py ├── OperationsBetweenNumbers.py └── OnTimeForTheExam.py ├── _04_ConditionalStatementsExercise ├── BonusScore.py ├── Time+15Minutes.py ├── SumSeconds.py ├── Shopping.py ├── LunchBreak.py ├── GodzillaVsKingKong.py ├── WorldSwimingRecord.py └── ToyShop.py ├── _12_Nested-Loops-Exercise ├── 05_password_generator.py ├── 01_number_pyramid.py ├── 02_equal_sums_even_odd_position.py ├── 03_sum_prime_non_prime.py ├── 04_train_the_trainers.py └── 06_special_numbers.py └── _10_While-Loop-Exercise ├── 01_old_books.py ├── 04_walking.py ├── 06_cake.py ├── 03_vacation.py ├── 02_exam_preparation.py └── 05_coins.py /README.md: -------------------------------------------------------------------------------- 1 | # Python_Basics -------------------------------------------------------------------------------- /_02_FirstStepsLab/Hello-Softuni.py: -------------------------------------------------------------------------------- 1 | print("Hello SoftUni"); -------------------------------------------------------------------------------- /_02_FirstStepsLab/GreetingsByName.py: -------------------------------------------------------------------------------- 1 | name = input(); 2 | print('Hello, ' + name + '!'); 3 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/NumbersFrom1to100.py: -------------------------------------------------------------------------------- 1 | for i in range(1, 101): 2 | print(f"{i}\n") 3 | 4 | 5 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/USDtoBGN.py: -------------------------------------------------------------------------------- 1 | usd = float(input()); 2 | bgn = usd * 1.79549; 3 | print(bgn); 4 | -------------------------------------------------------------------------------- /_02_FirstStepsLab/RectangleArea.py: -------------------------------------------------------------------------------- 1 | side1 = int(input()); 2 | side2 = int(input()); 3 | print(side1*side2); -------------------------------------------------------------------------------- /_07_ForLoop_lab/ReverseOrder_4.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | for i in range(num, 0, -1): 3 | print(i) 4 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/CharacterSequence.py: -------------------------------------------------------------------------------- 1 | text = input() 2 | for i in range(0, len(text)): 3 | print(text[i]) 4 | 5 | -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/01_clock.py: -------------------------------------------------------------------------------- 1 | for h in range(24): 2 | for m in range(60): 3 | print(f'{h}:{m}') 4 | -------------------------------------------------------------------------------- /_02_FirstStepsLab/InchesToSantimeters.py: -------------------------------------------------------------------------------- 1 | inches = float(input()); 2 | santimeters = inches*2.54; 3 | print(santimeters); -------------------------------------------------------------------------------- /_02_FirstStepsLab/PetShop.py: -------------------------------------------------------------------------------- 1 | foodDogs = int(input()); 2 | foodCats = int(input()); 3 | print(f'{foodDogs*2.5 + foodCats*4} lv.'); -------------------------------------------------------------------------------- /_07_ForLoop_lab/Numbers1to100stepBy3.py: -------------------------------------------------------------------------------- 1 | number = int(input()) 2 | for i in range(1, number + 1, 3): 3 | print(i) 4 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/ExcellentResult.py: -------------------------------------------------------------------------------- 1 | grade = float(input()) 2 | 3 | if grade >= 5.50: 4 | print("Excellent!") 5 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/EvenOrOdd.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | if num % 2 == 0: 3 | print('even') 4 | else: 5 | print('odd') 6 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/RadiansToDegrees.py: -------------------------------------------------------------------------------- 1 | radians = float(input()); 2 | from math import pi; 3 | degrees = radians * 180/pi; 4 | print(degrees); -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Numbers_ending_in_Seven_1.py: -------------------------------------------------------------------------------- 1 | for number in range(1, 1001): 2 | if number % 10 == 7: 3 | print(number) 4 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/EvenPowersOfNumberTwo_3.py: -------------------------------------------------------------------------------- 1 | number = int(input()) 2 | for i in range(0, number + 1): 3 | if i % 2 == 0: 4 | print(pow(2,i)) 5 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/04_sequence_2k+1.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | count = 1 4 | 5 | while count <= n: 6 | print(count) 7 | count = 2 * count+1 8 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/GreaterNumber.py: -------------------------------------------------------------------------------- 1 | num1 = int(input()) 2 | num2 = int(input()) 3 | 4 | if num1 >= num2: 5 | print(num1) 6 | else: print(num2) 7 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/PasswordGues.py: -------------------------------------------------------------------------------- 1 | password = input() 2 | if password == 's3cr3t!P@ssw0rd': 3 | print('Welcome') 4 | else: 5 | print('Wrong password!') -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/VocationBookList.py - Shortcut.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danovd/Python_Basics/HEAD/_02_FirstStepsExsercise/VocationBookList.py - Shortcut.lnk -------------------------------------------------------------------------------- /_02_FirstStepsLab/ProjectCreation.py: -------------------------------------------------------------------------------- 1 | name = input(); 2 | amount = int(input()); 3 | print(f'The architect {name} will need {amount*3} hours to complete {amount} project/s.'); -------------------------------------------------------------------------------- /_02_FirstStepsLab/Numbers1-10.py: -------------------------------------------------------------------------------- 1 | print(1); 2 | print(2); 3 | print(3); 4 | print(4); 5 | print(5); 6 | print(6); 7 | print(7); 8 | print(8); 9 | print(9); 10 | print(10); -------------------------------------------------------------------------------- /_09_While-Loop-Lab/01_read_text.py: -------------------------------------------------------------------------------- 1 | text = input() 2 | 3 | count = 0 4 | 5 | while text != "Stop": 6 | text = input() 7 | count += 1 8 | 9 | print(count) 10 | -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/02_multiplication_table.py: -------------------------------------------------------------------------------- 1 | for x in range(1, 11): 2 | for y in range(1, 11): 3 | product = x * y 4 | print(f'{x} * {y} = {product}') 5 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/NumberInRange.py: -------------------------------------------------------------------------------- 1 | number = int(input()) 2 | if -100 <= number <= 100 and number != 0: 3 | print("Yes") 4 | else: 5 | print("No") 6 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/InvalidNumber.py: -------------------------------------------------------------------------------- 1 | number = int(input()) 2 | 3 | if 100 <= number <= 200 or number == 0: 4 | number = number 5 | else: 6 | print("invalid") 7 | -------------------------------------------------------------------------------- /_02_FirstStepsLab/ConcatenateData.py: -------------------------------------------------------------------------------- 1 | name = input(); 2 | family = input(); 3 | age = int(input()); 4 | town = input(); 5 | print(f'You are {name} {family}, a {age}-years old person from {town}.'); -------------------------------------------------------------------------------- /_07_ForLoop_lab/SumNumbers.py: -------------------------------------------------------------------------------- 1 | numbers = int(input()) 2 | result = 0 3 | for num in range(0, numbers): 4 | current_number = int(input()) 5 | result += current_number 6 | print(result) 7 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/03_sum_numbers.py: -------------------------------------------------------------------------------- 1 | number = input() 2 | 3 | sum_nums = 0 4 | 5 | while number != 'Stop': 6 | sum_nums += int(number) 7 | number = input() 8 | 9 | print(sum_nums) 10 | -------------------------------------------------------------------------------- /_02_FirstStepsLab/YardGreening.py: -------------------------------------------------------------------------------- 1 | square = float(input()); 2 | 3 | square *= 7.61; 4 | discount = 0.18*square; 5 | square *= 0.82; 6 | print(f'The final price is: {square} lv.\nThe discount is: {discount} lv.'); 7 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/Number100to200.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | if num < 100: 3 | print('Less than 100') 4 | elif num <= 200: 5 | print('Between 100 and 200') 6 | else: 7 | print("Greater than 200") -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/BasketballEquipment.py: -------------------------------------------------------------------------------- 1 | yearTax = int(input()); 2 | shoes = 0.6 * yearTax; 3 | equip = 0.8 * shoes; 4 | ball = equip/4; 5 | accessories = ball / 5; 6 | 7 | yearTax += shoes + equip + ball + accessories; 8 | print(yearTax); -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/AnimalType.py: -------------------------------------------------------------------------------- 1 | animal = input() 2 | 3 | if animal == "dog": 4 | print("mammal") 5 | elif animal == "crocodile" or animal == "tortoise" or animal == "snake": 6 | print("reptile") 7 | else: 8 | print("unknown") 9 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/02_password.py: -------------------------------------------------------------------------------- 1 | name = input() 2 | password = input() 3 | input_password = input() 4 | 5 | while input_password != password: 6 | input_password = input() 7 | 8 | if input_password == password: 9 | print(f'Welcome {name}!') 10 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/CinemaTicket.py: -------------------------------------------------------------------------------- 1 | day = input() 2 | if day == "Monday" or day == "Tuesday" or day == "Friday": 3 | print(12) 4 | elif day == "Wednesday" or day == "Thursday": 5 | print(14) 6 | elif day == "Saturday" or day == "Sunday": 7 | print(16) 8 | -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/03_combinations.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | counter = 0 4 | 5 | for x1 in range(0, n+1): 6 | for x2 in range(0, n+1): 7 | for x3 in range(0, n+1): 8 | if x1+x2+x3 == n: 9 | counter += 1 10 | 11 | print(f'{counter}') 12 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/DepositCalculator.py: -------------------------------------------------------------------------------- 1 | depositAmount = float(input()); 2 | termInMonths = int(input()); 3 | yearInterest = float(input()); 4 | interestForOneYear = depositAmount*yearInterest/100; 5 | earnInterest = termInMonths/12*interestForOneYear; 6 | print(earnInterest+depositAmount); -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/SpeedInfo.py: -------------------------------------------------------------------------------- 1 | speed = float(input()) 2 | if speed <= 10: 3 | print('slow') 4 | elif speed <= 50: 5 | print('average') 6 | elif speed <= 150: 7 | print('fast') 8 | elif speed <= 1000: 9 | print('ultra fast') 10 | else: 11 | print('extremely fast') -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/WeekendOrWorkingDay.py: -------------------------------------------------------------------------------- 1 | day = input() 2 | if day == "Monday" or day == "Tuesday" or day == "Wednesday" or day == "Thursday" or day == "Friday": 3 | print("Working day") 4 | elif day == "Sunday" or day == "Saturday": 5 | print("Weekend") 6 | else: 7 | print("Error") 8 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/PersonalTitles.py: -------------------------------------------------------------------------------- 1 | age = float(input()) 2 | sex = input(); 3 | if sex == "m": 4 | if age < 16: 5 | print("Master") 6 | else: 7 | print("Mr.") 8 | else: 9 | if age < 16: 10 | print("Miss") 11 | else: 12 | print("Ms.") 13 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/07_min_number.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | numbers = int(input()) 4 | 5 | count = 0 6 | min_num = sys.maxsize 7 | 8 | while count != numbers: 9 | new_number = int(input()) 10 | count += 1 11 | if new_number < min_num: 12 | min_num = new_number 13 | 14 | print(f'{min_num}') 15 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/06_max_number.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | numbers = int(input()) 4 | 5 | count = 0 6 | max_num = -sys.maxsize 7 | 8 | while count != numbers: 9 | new_number = int(input()) 10 | count += 1 11 | if new_number > max_num: 12 | max_num = new_number 13 | 14 | print(f'{max_num}') 15 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/Cinema.py: -------------------------------------------------------------------------------- 1 | screening_type = input() 2 | rows = int(input()) 3 | cols = int(input()) 4 | result = rows * cols 5 | if screening_type == "Premiere": 6 | result *= 12 7 | elif screening_type == "Normal": 8 | result *= 7.5 9 | elif screening_type == "Discount": 10 | result *= 5 11 | print(f"{result:.2f}") 12 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/FishTank.py: -------------------------------------------------------------------------------- 1 | length = int(input()); 2 | width = int(input()); 3 | height = int(input()); 4 | percent = float(input()); 5 | 6 | # use width variable for volume instead of creating new one 7 | width *= 0.1; 8 | length *= 0.1; 9 | height *= 0.1; 10 | 11 | width *= length * height; 12 | width = width - (width*percent/100); 13 | print(width); -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/BonusScore.py: -------------------------------------------------------------------------------- 1 | num = int(input()) 2 | bonus = 0 3 | if num <= 100: 4 | bonus += 5 5 | elif num <= 1000: 6 | bonus = 0.2 * num 7 | elif num > 1000: 8 | bonus = 0.1 * num 9 | 10 | if num % 2 == 0: 11 | bonus += 1 12 | elif num % 10 == 5: 13 | bonus += 2 14 | 15 | print(bonus) 16 | print(bonus + num) 17 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/FoodDelivery.py: -------------------------------------------------------------------------------- 1 | chicken = int(input()); 2 | fish = int(input()); 3 | vegetarian = int(input()); 4 | 5 | chicken *= 10.35; 6 | fish *= 12.40; 7 | vegetarian *= 8.15; 8 | 9 | # use chicken variable instead of creating new one 10 | 11 | chicken += fish; 12 | chicken += vegetarian; 13 | 14 | chicken *= 1.2; 15 | chicken += 2.5; 16 | 17 | print(chicken); -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/05_travelling.py: -------------------------------------------------------------------------------- 1 | while True: 2 | destination = input() 3 | if destination == "End": 4 | break 5 | budget = float(input()) 6 | total_saved_money = 0 7 | 8 | while total_saved_money < budget: 9 | saved_money = float(input()) 10 | total_saved_money += saved_money 11 | 12 | print(f'Going to {destination}!') 13 | -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/06_building.py: -------------------------------------------------------------------------------- 1 | floors = int(input()) 2 | rooms = int(input()) 3 | 4 | for f in range(floors, 0, -1): 5 | for r in range(rooms): 6 | if f == floors: 7 | print(f'L{f}{r}', end=' ') 8 | elif f % 2 == 0: 9 | print(f'O{f}{r}', end=' ') 10 | else: 11 | print(f'A{f}{r}', end=' ') 12 | print() 13 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/FruitOrVegetable.py: -------------------------------------------------------------------------------- 1 | fruit = input() 2 | if fruit == "banana" or fruit == "kiwi" or fruit == "apple" or fruit == "cherry" or fruit == "lemon"\ 3 | or fruit == "grapes": 4 | print("fruit") 5 | elif fruit == "tomato" or fruit == "cucumber" or fruit == "pepper" or fruit == "carrot": 6 | print("vegetable") 7 | else: 8 | print("unknown") 9 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/08_graduation.py: -------------------------------------------------------------------------------- 1 | name = input() 2 | 3 | count = 0 4 | sum_grades = 0 5 | 6 | while count != 12: 7 | grade = float(input()) 8 | if grade < 4: 9 | continue 10 | else: 11 | count += 1 12 | sum_grades += grade 13 | 14 | average_grades = sum_grades / count 15 | 16 | print(f'{name} graduated. Average grade: {average_grades:.2f}') 17 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/WorkingHours.py: -------------------------------------------------------------------------------- 1 | hour = int(input()) 2 | day = input() 3 | if day == "Monday" or day == "Tuesday" or day == "Wednesday" or day == "Thursday" or day == "Friday"\ 4 | or day == "Saturday": 5 | if 10 <= hour <= 18: 6 | print("open") 7 | else: 8 | print("closed") 9 | elif day == "Sunday": 10 | print("closed") 11 | 12 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/SuppliesForSchool.py: -------------------------------------------------------------------------------- 1 | numberPens = int(input()); 2 | numberMarkers = int(input()); 3 | litersDetergent = int(input()); 4 | percentDiscount = int(input()); 5 | 6 | numberPens *= 5.8; 7 | numberMarkers *= 7.2; 8 | litersDetergent *= 1.2; 9 | 10 | result = numberPens + numberMarkers + litersDetergent; 11 | result = result - (result * percentDiscount/100); 12 | print(result); -------------------------------------------------------------------------------- /_07_ForLoop_lab/VowelsSum.py: -------------------------------------------------------------------------------- 1 | text = input() 2 | result = 0 3 | for char in range(0, len(text)): 4 | if text[char] == 'a': 5 | result += 1 6 | elif text[char] == 'e': 7 | result += 2 8 | elif text[char] == 'i': 9 | result += 3 10 | elif text[char] == 'o': 11 | result += 4 12 | elif text[char] == 'u': 13 | result += 5 14 | print(result) 15 | -------------------------------------------------------------------------------- /_02_FirstStepsExsercise/Repainting.py: -------------------------------------------------------------------------------- 1 | nylon = int(input()); 2 | paint = int(input()); 3 | thinner = int(input()); 4 | hoursForWork = int(input()); 5 | 6 | nylon *= 1.5; 7 | paint *= 14.5; 8 | thinner *= 5; 9 | 10 | paint *= 1.1; 11 | nylon += 3; 12 | result = nylon + paint + thinner; 13 | result += 0.4; 14 | 15 | hoursForWork *= result*0.3; 16 | result += hoursForWork; 17 | 18 | print(result); 19 | -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/Time+15Minutes.py: -------------------------------------------------------------------------------- 1 | hours = int(input()) 2 | minutes = int(input()) 3 | 4 | minutes += 15 5 | totalInMinutes = hours*60 + minutes 6 | if minutes > 59: 7 | hours += 1 8 | minutes = minutes - 60 9 | 10 | if totalInMinutes >= 24*60: 11 | hours = hours - 24 12 | 13 | if minutes < 10: 14 | print(f'{hours}:0{minutes}') 15 | else: 16 | print(f'{hours}:{minutes}') -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/SumSeconds.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | first = int(input()) 4 | second = int(input()) 5 | third = int(input()) 6 | 7 | totalSeconds = first + second + third 8 | 9 | minutes = totalSeconds // 60 10 | seconds = totalSeconds % 60 11 | 12 | # minutes = math.floor(minutes) 13 | 14 | if seconds < 10: 15 | print(f'{minutes}:0{seconds}') 16 | else: 17 | print(f'{minutes}:{seconds}') 18 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/05_account_balance.py: -------------------------------------------------------------------------------- 1 | payment_qty = int(input()) 2 | 3 | balance = 0 4 | count = 0 5 | 6 | while count != payment_qty: 7 | payment = float(input()) 8 | if payment < 0: 9 | print('Invalid operation!') 10 | break 11 | else: 12 | balance += payment 13 | count += 1 14 | print(f'Increase: {payment:.2f}') 15 | 16 | print(f'Total: {balance:.2f}') 17 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/DayOfWeek.py: -------------------------------------------------------------------------------- 1 | day = int(input()) 2 | if day == 1: 3 | print("Monday") 4 | elif day == 2: 5 | print("Tuesday") 6 | elif day == 3: 7 | print("Wednesday") 8 | elif day == 4: 9 | print("Thursday") 10 | elif day == 5: 11 | print("Friday") 12 | elif day == 6: 13 | print("Saturday") 14 | elif day == 7: 15 | print("Sunday") 16 | else: print("Error") 17 | 18 | 19 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/05_password_generator.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | l = int(input()) 3 | letter = 97 + l 4 | for i in range(1, n + 1): 5 | for j in range(1, n + 1): 6 | for k in range(97, letter): 7 | for m in range(97, letter): 8 | for p in range(2, n + 1): 9 | if (p > i) and (p > j): 10 | print(f"{i}{j}{chr(k)}{chr(m)}{p}", end=" ") 11 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/Number_Sequence_8.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | numbers = int(input()) 4 | minimum = sys.maxsize 5 | maximum = - sys.maxsize 6 | for number in range(0, numbers): 7 | current_number = int(input()) 8 | if current_number < minimum: 9 | minimum = current_number 10 | if current_number > maximum: 11 | maximum = current_number 12 | print(f"Max number: {maximum}") 13 | print(f"Min number: {minimum}") 14 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/01_old_books.py: -------------------------------------------------------------------------------- 1 | title = input() 2 | books_qty = int(input()) 3 | 4 | count = 0 5 | 6 | while count != books_qty: 7 | next_title = input() 8 | if next_title != title: 9 | count += 1 10 | else: 11 | print(f'You checked {count} books and found it.') 12 | break 13 | 14 | if count == books_qty: 15 | print(f'The book you search is not here!\nYou checked {count} books.') 16 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/01_number_pyramid.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | current = 1 4 | is_current_bigger_than_n = False 5 | 6 | for row in range(1, n+1): 7 | for col in range(1, row+1): 8 | if current > n: 9 | is_current_bigger_than_n = True 10 | break 11 | print(str(current) + ' ', end='') 12 | current += 1 13 | if is_current_bigger_than_n: 14 | break 15 | print() 16 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/Left_and_Right_SUM_9.py: -------------------------------------------------------------------------------- 1 | numbers = int(input()) 2 | sum_left = 0 3 | sum_right = 0 4 | for number in range(0, numbers): 5 | current_number = int(input()) 6 | sum_left += current_number 7 | for number in range(0, numbers): 8 | current_number = int(input()) 9 | sum_right += current_number 10 | if sum_left == sum_right: 11 | print(f"Yes, sum = {sum_left}") 12 | else: 13 | print(f"No, diff = {abs(sum_left - sum_right)}") 14 | -------------------------------------------------------------------------------- /_07_ForLoop_lab/Odd_Even_sum_10.py: -------------------------------------------------------------------------------- 1 | numbers = int(input()) 2 | even_position__sum = 0 3 | odd_position_sum = 0 4 | for number in range(0, numbers): 5 | current_number = int(input()) 6 | if number % 2 == 0: 7 | even_position__sum += current_number 8 | else: 9 | odd_position_sum += current_number 10 | 11 | if even_position__sum == odd_position_sum: 12 | print(f"Yes\nSum = {even_position__sum}") 13 | else: 14 | print(f"No\nDiff = {abs(even_position__sum - odd_position_sum)}") 15 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/02_equal_sums_even_odd_position.py: -------------------------------------------------------------------------------- 1 | start_num = int(input()) 2 | end_num = int(input()) 3 | 4 | for num in range(start_num, end_num+1): 5 | num_as_string = str(num) 6 | odd_sum = 0 7 | even_sum = 0 8 | for i in range(0, len(num_as_string)): 9 | digit = int(num_as_string[i]) 10 | if (i+1) % 2 == 0: 11 | even_sum += digit 12 | else: 13 | odd_sum += digit 14 | if even_sum == odd_sum: 15 | print(num, end=' ') 16 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/04_walking.py: -------------------------------------------------------------------------------- 1 | steps_count = 0 2 | goal = 10000 3 | 4 | while steps_count < goal: 5 | command = input() 6 | if command == 'Going home': 7 | steps_to_home = int(input()) 8 | steps_count += steps_to_home 9 | break 10 | else: 11 | walked_steps = int(command) 12 | steps_count += walked_steps 13 | 14 | if steps_count >= goal: 15 | print(f'Goal reached! Good job!') 16 | else: 17 | print(f'{goal - steps_count} more steps to reach goal.') 18 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Salary_5.py: -------------------------------------------------------------------------------- 1 | tabs = int(input()) 2 | salary = int(input()) 3 | penalty = 0 4 | for tab in range(0, tabs): 5 | current_tab = input() 6 | if current_tab == "Facebook": 7 | penalty = 150 8 | elif current_tab == "Instagram": 9 | penalty = 100 10 | elif current_tab == "Reddit": 11 | penalty = 50 12 | salary -= penalty 13 | penalty = 0 14 | if salary <= 0: 15 | print("You have lost your salary.") 16 | break 17 | if salary > 0: 18 | print(salary) 19 | -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/Shopping.py: -------------------------------------------------------------------------------- 1 | budget = float(input()) 2 | cards = int(input()) 3 | cpus = int(input()) 4 | ram = int(input()) 5 | 6 | sumCards = cards * 250 7 | priceCPU = 0.35 * sumCards 8 | priceRAM = 0.1 * sumCards 9 | 10 | theSum = sumCards + priceCPU * cpus + priceRAM * ram 11 | 12 | if cards > cpus: 13 | theSum *= 0.85 14 | 15 | if budget >= theSum: 16 | print(f'You have {"{:.2f}".format(budget - theSum)} leva left!') 17 | else: 18 | print(f'Not enough money! You need {"{:.2f}".format(theSum - budget)} leva more!') 19 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/09_graduation_pt2.py: -------------------------------------------------------------------------------- 1 | name = input() 2 | 3 | count = 1 4 | excluded = 0 5 | sum_grades = 0 6 | 7 | while count <= 12: 8 | grade = float(input()) 9 | if grade < 4: 10 | excluded += 1 11 | if excluded == 2: 12 | break 13 | continue 14 | count += 1 15 | sum_grades += grade 16 | 17 | if count == 13: 18 | average_grades = sum_grades / 12 19 | print(f'{name} graduated. Average grade: {average_grades:.2f}') 20 | else: 21 | print(f'{name} has been excluded at {count} grade') 22 | -------------------------------------------------------------------------------- /_03_ConditionalStatementsLab/AreaOfFigure.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | typeOfFigure = input() 4 | 5 | if typeOfFigure == 'square': 6 | side = float(input()) 7 | print(side * side) 8 | elif typeOfFigure == 'rectangle': 9 | side1 = float(input()) 10 | side2 = float(input()) 11 | print(side1 * side2) 12 | elif typeOfFigure == 'circle': 13 | radius = float(input()) 14 | print(radius * radius * math.pi) 15 | elif typeOfFigure == 'triangle': 16 | length = float(input()) 17 | height = float(input()) 18 | print(length * height / 2) 19 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Half_sum_element_2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | numbers = int(input()) 4 | max_number = - sys.maxsize 5 | total_sum = 0 6 | for number in range(1, numbers + 1): 7 | current_number = int(input()) 8 | if current_number > max_number: 9 | max_number = current_number 10 | total_sum += current_number 11 | diff = total_sum - max_number 12 | sum_without_max_number = total_sum - max_number 13 | if max_number == diff: 14 | print(f"Yes\nSum = {diff}") 15 | else: 16 | print(f"No\nDiff = {abs(max_number - sum_without_max_number)}") 17 | -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/04_sum_of_two_numbers.py: -------------------------------------------------------------------------------- 1 | begin = int(input()) 2 | end = int(input()) 3 | magic_number = int(input()) 4 | 5 | counter_combination = 0 6 | 7 | for x in range(begin, end+1): 8 | for y in range(begin, end+1): 9 | counter_combination += 1 10 | if x+y == magic_number: 11 | print(f'Combination N:{counter_combination} ({x} + {y} = {magic_number})') 12 | break 13 | if x+y == magic_number: 14 | break 15 | 16 | if x+y != magic_number: 17 | print(f'{counter_combination} combinations - neither equals {magic_number}') 18 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Oscars_6.py: -------------------------------------------------------------------------------- 1 | name = input() 2 | points = float(input()) 3 | assessors = int(input()) 4 | 5 | for assessor in range(0, assessors): 6 | current_assessor = input() 7 | points_of_current_assessor = float(input()) 8 | points_of_current_assessor = (points_of_current_assessor * len(current_assessor))/2 9 | points += points_of_current_assessor 10 | if points > 1250.5: 11 | break 12 | if points > 1250.5: 13 | print(f"Congratulations, {name} got a nominee for leading role with {points:.1f}!") 14 | else: 15 | print(f"Sorry, {name} you need {(1250.5 - points):.1f} more!") -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/LunchBreak.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | name = input() 4 | durationSeries = int(input()) 5 | durationRest = int(input()) 6 | timeLunch = 1/8 * durationRest 7 | timeRest = 1/4 * durationRest 8 | 9 | durationRest -= (timeLunch + timeRest) 10 | 11 | 12 | if durationRest >= durationSeries: 13 | print(f'You have enough time to watch {name} and left with {math.ceil(durationRest - durationSeries)} ' 14 | f'minutes free time.') 15 | else: 16 | print(f"You don't have enough time to watch {name}, you need" 17 | f" {math.ceil(durationSeries - durationRest)} more minutes.") 18 | 19 | 20 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/03_sum_prime_non_prime.py: -------------------------------------------------------------------------------- 1 | command = input() 2 | 3 | sum_prime = 0 4 | sum_non_prime = 0 5 | 6 | while command != 'stop': 7 | num = int(command) 8 | if num < 0: 9 | print('Number is negative.') 10 | else: 11 | count = 0 12 | for i in range(1, num+1): 13 | if num % i == 0: 14 | count += 1 15 | if count == 2: 16 | sum_prime += num 17 | elif count > 2: 18 | sum_non_prime += num 19 | command = input() 20 | 21 | print(f'Sum of all prime numbers is: {sum_prime}') 22 | print(f'Sum of all non prime numbers is: {sum_non_prime}') 23 | -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/GodzillaVsKingKong.py: -------------------------------------------------------------------------------- 1 | budget = float(input()) 2 | statists = int(input()) 3 | priceClothesOneStatist = float(input()) 4 | 5 | totalSum = 0.1 * budget 6 | 7 | totalSumStatists = priceClothesOneStatist * statists 8 | 9 | if statists > 150: 10 | totalSumStatists = totalSumStatists - (totalSumStatists * 0.1) 11 | 12 | totalSum += totalSumStatists 13 | 14 | 15 | if totalSum > budget: 16 | print('Not enough money!') 17 | print(f'Wingard needs {"{:.2f}".format(totalSum - budget)} leva more.') 18 | else: 19 | print('Action!') 20 | print(f'Wingard starts filming with {"{:.2f}".format(budget - totalSum)} leva left.') 21 | -------------------------------------------------------------------------------- /_02_FirstStepsLab/main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | 3 | # Press Shift+F10 to execute it or replace it with your code. 4 | # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. 5 | 6 | 7 | def print_hi(name): 8 | # Use a breakpoint in the code line below to debug your script. 9 | print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. 10 | 11 | 12 | # Press the green button in the gutter to run the script. 13 | if __name__ == '__main__': 14 | print_hi('PyCharm') 15 | 16 | side = int(input()); 17 | side2 = float(input()); 18 | print(side2); 19 | # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 20 | -------------------------------------------------------------------------------- /_09_While-Loop-Lab/10_moving.py: -------------------------------------------------------------------------------- 1 | free_space_weight = int(input()) 2 | free_space_length = int(input()) 3 | free_space_high = int(input()) 4 | 5 | free_area = free_space_high * free_space_weight * free_space_length 6 | taken_area = 0 7 | 8 | while taken_area <= free_area: 9 | command = input() 10 | if command == 'Done': 11 | left_area = free_area-taken_area 12 | print(f'{left_area} Cubic meters left.') 13 | break 14 | else: 15 | box_qty = int(command) 16 | taken_area += box_qty 17 | 18 | if taken_area > free_area: 19 | needed_area = taken_area-free_area 20 | print(f'No more free space! You need {needed_area} Cubic meters more.') 21 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/06_cake.py: -------------------------------------------------------------------------------- 1 | cake_length = int(input()) 2 | cake_weight = int(input()) 3 | 4 | cake_area = cake_length * cake_weight 5 | cake_pieces_sum = 0 6 | 7 | while True: 8 | cake_pieces = input() 9 | if cake_pieces == 'STOP': 10 | cake_pieces_left = cake_area-cake_pieces_sum 11 | print(f"{cake_pieces_left} pieces are left.") 12 | break 13 | else: 14 | new_cake_pieces = int(cake_pieces) 15 | cake_pieces_sum += new_cake_pieces 16 | if cake_pieces_sum > cake_area: 17 | needed_pieces = cake_pieces_sum - cake_area 18 | print(f"No more cake left! You need {needed_pieces} pieces more.") 19 | break 20 | -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/WorldSwimingRecord.py: -------------------------------------------------------------------------------- 1 | import math 2 | recordInSeconds = float(input()) 3 | distanceInMeters = float(input()) 4 | timeInSecondsForOneMeter = float(input()) 5 | 6 | timeForAllDistance = distanceInMeters * timeInSecondsForOneMeter 7 | timesDelay = int(distanceInMeters / 15) 8 | totalDelay = timesDelay * 12.5 9 | 10 | timeForAllDistance += totalDelay 11 | 12 | if timeForAllDistance < recordInSeconds: # "{:.2f}".format(timeForAllDistance) 13 | print(f"Yes, he succeeded! The new world record is {'{:.2f}'.format(timeForAllDistance)} seconds.") 14 | 15 | else: 16 | print(f"No, he failed! He was {'{:.2f}'.format(timeForAllDistance - recordInSeconds)} seconds slower.") 17 | -------------------------------------------------------------------------------- /_04_ConditionalStatementsExercise/ToyShop.py: -------------------------------------------------------------------------------- 1 | priceTrip = float(input()) 2 | amountPuzzels = int(input()) 3 | amountDolls = int(input()) 4 | amountBears = int(input()) 5 | amountMinons = int(input()) 6 | amountTracks = int(input()) 7 | 8 | amountToysTotal = amountTracks + amountMinons + amountBears + amountDolls + amountPuzzels 9 | totalSum = amountTracks * 2 + amountPuzzels * 2.6 + amountDolls * 3 + amountBears * 4.1 + amountMinons * 8.2 10 | 11 | if amountToysTotal >= 50: 12 | totalSum *= 0.75 13 | 14 | totalSum *= 0.9 15 | 16 | if totalSum < priceTrip: 17 | print(f"Not enough money! {'{:.2f}'.format(priceTrip - totalSum)} lv needed.") 18 | else: 19 | print(f'Yes! {"{:.2f}".format(totalSum - priceTrip)} lv left.') 20 | 21 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Clever_lily_4.py: -------------------------------------------------------------------------------- 1 | age = int(input()) 2 | price_of_aim = float(input()) 3 | price_of_single_toy = int(input()) 4 | number_of_received_toys = 0 5 | amount_of_money_for_current_birthday = 10 6 | received_money = 0 7 | for year in range(1, age + 1): 8 | if year % 2 != 0: 9 | number_of_received_toys += 1 10 | else: 11 | received_money += amount_of_money_for_current_birthday 12 | amount_of_money_for_current_birthday += 10 13 | received_money -= 1 14 | received_money += (number_of_received_toys * price_of_single_toy) 15 | if received_money >= price_of_aim: 16 | print(f"Yes! {(received_money - price_of_aim):.2f}") 17 | else: 18 | print(f"No! {(price_of_aim - received_money):.2f}") 19 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/04_train_the_trainers.py: -------------------------------------------------------------------------------- 1 | judges_qty = int(input()) 2 | 3 | total_sum_average_evaluation = 0 4 | count = 0 5 | 6 | while True: 7 | presentation_name = input() 8 | if presentation_name == 'Finish': 9 | break 10 | sum_evaluation = 0 11 | for i in range(judges_qty): 12 | evaluation = float(input()) 13 | count += 1 14 | sum_evaluation += evaluation 15 | total_sum_average_evaluation += evaluation 16 | average_evaluation = sum_evaluation / judges_qty 17 | print(f'{presentation_name} - {average_evaluation:.2f}.') 18 | 19 | total_average_evaluation = total_sum_average_evaluation / count 20 | print(f'Student\'s final assessment is {total_average_evaluation:.2f}.') 21 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/03_vacation.py: -------------------------------------------------------------------------------- 1 | needed_money = float(input()) 2 | saved_money = float(input()) 3 | 4 | days_count = 0 5 | spend_count = 0 6 | 7 | while True: 8 | decision = input() 9 | money_for_all = float(input()) 10 | days_count += 1 11 | if decision == 'spend': 12 | spend_count += 1 13 | saved_money -= money_for_all 14 | if saved_money < 0: 15 | saved_money = 0 16 | if spend_count == 5: 17 | print(f"You can't save the money.\n{days_count}") 18 | break 19 | elif decision == 'save': 20 | spend_count = 0 21 | saved_money += money_for_all 22 | if saved_money >= needed_money: 23 | print(f"You saved the money for {days_count} days.") 24 | break 25 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/02_exam_preparation.py: -------------------------------------------------------------------------------- 1 | bad_grades_qty = int(input()) 2 | 3 | grades_sum = 0 4 | tasks_sum = 0 5 | last_task_name = '' 6 | bad_grades_count = 0 7 | 8 | while True: 9 | task_name = input() 10 | if task_name == 'Enough': 11 | average_grade = grades_sum / tasks_sum 12 | print(f'Average score: {average_grade:.2f}') 13 | print(f'Number of problems: {tasks_sum}') 14 | print(f'Last problem: {last_task_name}') 15 | break 16 | last_task_name = task_name 17 | grade = int(input()) 18 | if grade <= 4: 19 | bad_grades_count += 1 20 | if bad_grades_count == bad_grades_qty: 21 | print(f'You need a break, {bad_grades_count} poor grades.') 22 | break 23 | tasks_sum += 1 24 | grades_sum += grade 25 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/HotelRoom.py: -------------------------------------------------------------------------------- 1 | month = input() 2 | nights = int(input()) 3 | apartment_price = 0 4 | studio_price = 0 5 | if month == "May" or month == "October": 6 | studio_price = 50.0 7 | apartment_price = 65.0 8 | if 14 >= nights > 7: 9 | studio_price *= 0.95 10 | if nights > 14: 11 | studio_price *= 0.7 12 | elif month == "June" or month == "September": 13 | studio_price = 75.2 14 | apartment_price = 68.7 15 | if nights > 14: 16 | studio_price *= 0.8 17 | elif month == "July" or month == "August": 18 | studio_price = 76.0 19 | apartment_price = 77.0 20 | if nights > 14: 21 | apartment_price *= 0.9 22 | apartment_price *= nights 23 | studio_price *= nights 24 | print(f"Apartment: {apartment_price:.2f} lv.\nStudio: {studio_price:.2f} lv.") 25 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Tennis_Ranklist_8.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | number_competitions = int(input()) 4 | points = float(input()) 5 | earned_points = 0 6 | wins = 0 7 | for competition in range(0, number_competitions): 8 | result_in_current_competition = input() 9 | if result_in_current_competition == "W": 10 | earned_points += 2000 11 | wins += 1 12 | elif result_in_current_competition == "F": 13 | earned_points += 1200 14 | elif result_in_current_competition == "SF": 15 | earned_points += 720 16 | average_points_per_competition = earned_points / number_competitions 17 | wins = (wins / number_competitions) * 100 18 | points += earned_points 19 | print(f"Final points: {points:.0f}\nAverage points:" 20 | f" {math.floor(average_points_per_competition)}\n{wins:.2f}%") 21 | 22 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/SkiTrip.py: -------------------------------------------------------------------------------- 1 | days = int(input()) 2 | types = input() 3 | estimate = input() 4 | discount = 0 5 | price = 0 6 | if types == "room for one person": 7 | price = 18 8 | elif types == "apartment": 9 | price = 25 10 | if days <= 10: 11 | discount = 0.3 12 | elif 10 < days <= 15: 13 | discount = 0.35 14 | elif days > 15: 15 | discount = 0.5 16 | elif types == "president apartment": 17 | price = 35 18 | if days <= 10: 19 | discount = 0.1 20 | elif 10 < days <= 15: 21 | discount = 0.15 22 | elif days > 15: 23 | discount = 0.2 24 | result = price - (price * discount) 25 | result *= (days - 1) 26 | 27 | if estimate == "positive": 28 | result *= 1.25 29 | elif estimate == "negative": 30 | result *= 0.9 31 | 32 | print(f"{result:.2f}") 33 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/Journey.py: -------------------------------------------------------------------------------- 1 | budget = float(input()) 2 | season = input() 3 | expenses = 0 4 | destination = "" 5 | place_for_night = "" 6 | 7 | if budget <= 100: 8 | destination = "Bulgaria" 9 | if season == "summer": 10 | expenses = 0.3 11 | place_for_night = "Camp" 12 | elif season == "winter": 13 | expenses = 0.7 14 | place_for_night = "Hotel" 15 | elif budget <= 1000: 16 | destination = "Balkans" 17 | if season == "summer": 18 | expenses = 0.4 19 | place_for_night = "Camp" 20 | elif season == "winter": 21 | expenses = 0.8 22 | place_for_night = "Hotel" 23 | elif budget > 1000: 24 | destination = "Europe" 25 | expenses = 0.9 26 | place_for_night = "Hotel" 27 | 28 | print(f"Somewhere in {destination}\n{place_for_night} - {(budget * expenses):.2f}") 29 | 30 | -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Histogram_3.py: -------------------------------------------------------------------------------- 1 | numbers = int(input()) 2 | amount_200 = 0 3 | amount_200_400 = 0 4 | amount_400_600 = 0 5 | amount_600_800 = 0 6 | amount_plus_800 = 0 7 | for number in range(0, numbers): 8 | current_number = int(input()) 9 | if current_number < 200: 10 | amount_200 += 1 11 | elif 200 <= current_number < 400: 12 | amount_200_400 += 1 13 | elif 400 <= current_number < 600: 14 | amount_400_600 += 1 15 | elif 600 <= current_number < 800: 16 | amount_600_800 += 1 17 | elif 800 <= current_number: 18 | amount_plus_800 += 1 19 | 20 | print(f"{((amount_200 / numbers) * 100):.2f}%") 21 | print(f"{((amount_200_400 / numbers) * 100):.2f}%") 22 | print(f"{((amount_400_600 / numbers) * 100):.2f}%") 23 | print(f"{((amount_600_800 / numbers) * 100):.2f}%") 24 | print(f"{((amount_plus_800 / numbers) * 100):.2f}%") 25 | -------------------------------------------------------------------------------- /_12_Nested-Loops-Exercise/06_special_numbers.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | # 1. генерираме всички числа от 1111 до 9999 3 | # 2. за всяко едно число да го разбием на цифри 4 | # 3. проверка дали е специално -> ако е специално го печатаме 5 | 6 | for number in range(1111, 10000): 7 | # разбивка 8 | first_digit = number // 1000 9 | second_digit = (number // 100) % 10 10 | third_digit = (number // 10) % 10 11 | forth_digit = number % 10 12 | 13 | # специално: 1. n % first == 0; 2. n % second == 0; 3. n % third == 0; 14 | # 4. n % forth == 0 15 | check1 = first_digit != 0 and n % first_digit == 0 16 | check2 = second_digit != 0 and n % second_digit == 0 17 | check3 = third_digit != 0 and n % third_digit == 0 18 | check4 = forth_digit != 0 and n % forth_digit == 0 19 | 20 | if check1 and check2 and check3 and check4: 21 | print(str(number)+' ', end='') 22 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/SummerOutfit.py: -------------------------------------------------------------------------------- 1 | degrees = int(input()) 2 | time_of_day = input() 3 | outfit = "" 4 | shoes = "" 5 | if time_of_day == "Morning": 6 | if 10 <= degrees <= 18: 7 | outfit = "Sweatshirt" 8 | shoes = "Sneakers" 9 | elif 18 < degrees <= 24: 10 | outfit = "Shirt" 11 | shoes = "Moccasins" 12 | elif degrees > 24: 13 | outfit = "T-Shirt" 14 | shoes = "Sandals" 15 | elif time_of_day == "Afternoon": 16 | if 10 <= degrees <= 18: 17 | outfit = "Shirt" 18 | shoes = "Moccasins" 19 | elif 18 < degrees <= 24: 20 | outfit = "T-Shirt" 21 | shoes = "Sandals" 22 | elif degrees > 24: 23 | outfit = "Swim Suit" 24 | shoes = "Barefoot" 25 | elif time_of_day == "Evening": 26 | outfit = "Shirt" 27 | shoes = "Moccasins" 28 | print(f"It's {degrees} degrees, get your {outfit} and {shoes}.") -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/FishingBoat.py: -------------------------------------------------------------------------------- 1 | budget = int(input()) 2 | season = input() 3 | number_fishers = int(input()) 4 | rent_of_boat = 0; 5 | discount = 0; 6 | if season == "Spring": 7 | rent_of_boat = 3000 8 | elif season == "Summer" or season == "Autumn": 9 | rent_of_boat = 4200 10 | elif season == "Winter": 11 | rent_of_boat = 2600 12 | 13 | if 1 <= number_fishers <= 6: 14 | discount = 0.1 15 | elif 6 < number_fishers <= 11: 16 | discount = 0.15 17 | elif number_fishers >= 12: 18 | discount = 0.25 19 | 20 | rent_of_boat = rent_of_boat - (rent_of_boat * discount) 21 | 22 | if number_fishers %2 == 0 and season != "Autumn": 23 | discount = 0.05 24 | else: 25 | discount = 0 26 | 27 | rent_of_boat = rent_of_boat - (rent_of_boat * discount) 28 | 29 | if budget >= rent_of_boat: 30 | print(f"Yes! You have {(budget - rent_of_boat):.2f} leva left.") 31 | else: 32 | print(f"Not enough money! You need {(rent_of_boat - budget):.2f} leva.") -------------------------------------------------------------------------------- /_08_For_Loop_Exercise/Trekking_mania_7.py: -------------------------------------------------------------------------------- 1 | number_groups = int(input()) 2 | musala = 0 3 | monblan = 0 4 | kilimandjaro = 0 5 | k2 = 0 6 | everest = 0 7 | all_climbers = 0 8 | for group in range(0, number_groups): 9 | number_people_in_current_group = int(input()) 10 | all_climbers += number_people_in_current_group 11 | if number_people_in_current_group < 6: 12 | musala += number_people_in_current_group 13 | elif 5 < number_people_in_current_group < 13: 14 | monblan += number_people_in_current_group 15 | elif 12 < number_people_in_current_group < 26: 16 | kilimandjaro += number_people_in_current_group 17 | elif 25 < number_people_in_current_group < 41: 18 | k2 += number_people_in_current_group 19 | elif 40 < number_people_in_current_group: 20 | everest += number_people_in_current_group 21 | 22 | print(f"{((musala / all_climbers) * 100):.2f}%") 23 | print(f"{((monblan / all_climbers) * 100):.2f}%") 24 | print(f"{((kilimandjaro / all_climbers) * 100):.2f}%") 25 | print(f"{((k2 / all_climbers) * 100):.2f}%") 26 | print(f"{((everest / all_climbers) * 100):.2f}%") 27 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/SmallShop.py: -------------------------------------------------------------------------------- 1 | product = input() 2 | city = input() 3 | quantity = float(input()) 4 | price = float(0.0); 5 | if city == "Sofia": 6 | if product == "coffee": 7 | price = 0.5 8 | elif product == "water": 9 | price = 0.8 10 | elif product == "beer": 11 | price = 1.2 12 | elif product == "sweets": 13 | price = 1.45 14 | elif product == "peanuts": 15 | price = 1.6 16 | elif city == "Plovdiv": 17 | if product == "coffee": 18 | price = 0.4 19 | elif product == "water": 20 | price = 0.7 21 | elif product == "beer": 22 | price = 1.15 23 | elif product == "sweets": 24 | price = 1.3 25 | elif product == "peanuts": 26 | price = 1.5 27 | elif city == "Varna": 28 | if product == "coffee": 29 | price = 0.45 30 | elif product == "water": 31 | price = 0.7 32 | elif product == "beer": 33 | price = 1.1 34 | elif product == "sweets": 35 | price = 1.35 36 | elif product == "peanuts": 37 | price = 1.55 38 | 39 | print(price * quantity) 40 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/NewHouse.py: -------------------------------------------------------------------------------- 1 | type_flower = input() 2 | number_flowers = int(input()) 3 | budget = int(input()) 4 | discount = 0; 5 | price_of_Flower = 0 6 | if type_flower == "Roses": 7 | price_of_Flower = 5 8 | if number_flowers > 80: 9 | discount = 0.10 10 | elif type_flower == "Dahlias": 11 | price_of_Flower = 3.8 12 | if number_flowers > 90: 13 | discount = 0.15 14 | elif type_flower == "Tulips": 15 | price_of_Flower = 2.8 16 | if number_flowers > 80: 17 | discount = 0.15 18 | elif type_flower == "Narcissus": 19 | price_of_Flower = 3 20 | if number_flowers < 120: 21 | discount = -0.15 22 | elif type_flower == "Gladiolus": 23 | price_of_Flower = 2.5 24 | if number_flowers < 80: 25 | discount = -0.20 26 | result = number_flowers * price_of_Flower 27 | result = result - (result * discount) 28 | if budget >= result: 29 | print(f"Hey, you have a great garden with {number_flowers:.0f} {type_flower} and {(budget - result):.2f}" 30 | f" leva left.") 31 | else: 32 | print(f"Not enough money, you need {(result-budget):.2f} leva more.") -------------------------------------------------------------------------------- /_11_Nested-Loops-Lab/07_cinema_tickets.py: -------------------------------------------------------------------------------- 1 | ticket_counter = 0 2 | student_counter = 0 3 | standard_counter = 0 4 | kid_counter = 0 5 | 6 | while True: 7 | film_name = input() 8 | if film_name == 'Finish': 9 | break 10 | free_places = int(input()) 11 | taken_places = 0 12 | while free_places > taken_places: 13 | ticket_type = input() 14 | if ticket_type == 'End': 15 | break 16 | ticket_counter += 1 17 | taken_places += 1 18 | if ticket_type == 'student': 19 | student_counter +=1 20 | elif ticket_type == 'standard': 21 | standard_counter +=1 22 | elif ticket_type == 'kid': 23 | kid_counter += 1 24 | result1 = taken_places / free_places * 100 25 | print(f'{film_name} - {result1:.2f}% full.') 26 | 27 | result2 = student_counter / ticket_counter * 100 28 | result3 = standard_counter / ticket_counter * 100 29 | result4 = kid_counter / ticket_counter * 100 30 | 31 | print(f'Total tickets: {ticket_counter}\n{result2:.2f}% student tickets.\n{result3:.2f}% standard tickets.\n' 32 | f'{result4:.2f}% kids tickets.') 33 | -------------------------------------------------------------------------------- /_10_While-Loop-Exercise/05_coins.py: -------------------------------------------------------------------------------- 1 | # спираме да връщаме ресто: ресто == 0 2 | # връщаме ресто: ресто != 0 3 | change_in_leva = float(input()) 4 | change = round(change_in_leva * 100) 5 | 6 | count_coins = 0 7 | while change != 0: 8 | # проверки за монетите 9 | if change >= 200: 10 | # 2 + 11 | change -= 200 12 | count_coins += 1 13 | elif change >= 100: 14 | # 1 -> 1.99 15 | change -= 100 16 | count_coins += 1 17 | elif change >= 50: 18 | # 0.50 -> 0.99 19 | change -= 50 20 | count_coins += 1 21 | elif change >= 20: 22 | # 0.20 -> 0.49 23 | change -= 20 24 | count_coins += 1 25 | elif change >= 10: 26 | # 0.10 -> 0.19 27 | change -= 10 28 | count_coins += 1 29 | elif change >= 5: 30 | # 0.05 -> 0.09 31 | change -= 5 32 | count_coins += 1 33 | elif change >= 2: 34 | # 0.02 -> 0.04 35 | change -= 2 36 | count_coins += 1 37 | elif change >= 1: 38 | # 0.01 39 | change -= 1 40 | count_coins += 1 41 | else: 42 | print(count_coins) 43 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/OperationsBetweenNumbers.py: -------------------------------------------------------------------------------- 1 | num1 = int(input()) 2 | num2 = int(input()) 3 | operator = input() 4 | result = 0 5 | isEven = True 6 | 7 | if operator == "+": 8 | result = num1 + num2 9 | if result % 2 == 0: 10 | print(f"{num1} + {num2} = {(num1+num2):.0f} - even") 11 | else: 12 | print(f"{num1} + {num2} = {(num1+num2):.0f} - odd") 13 | elif operator == "-": 14 | result = num1 - num2 15 | if result % 2 == 0: 16 | print(f"{num1} - {num2} = {(num1-num2):.0f} - even") 17 | else: 18 | print(f"{num1} - {num2} = {(num1-num2):.0f} - odd") 19 | elif operator == "*": 20 | result = num1 * num2 21 | if result % 2 == 0: 22 | print(f"{num1} * {num2} = {(num1*num2):.0f} - even") 23 | else: 24 | print(f"{num1} * {num2} = {(num1*num2):.0f} - odd") 25 | elif operator == "/": 26 | if num2 == 0: 27 | print(f"Cannot divide {num1} by zero") 28 | else: 29 | result = num1 / num2 30 | print(f"{num1} / {num2} = {(num1/num2):.2f}") 31 | elif operator == "%": 32 | if num2 == 0: 33 | print(f"Cannot divide {num1} by zero") 34 | else: 35 | result = num1 % num2 36 | symbol = '%' 37 | print(f"{num1} {symbol} {num2} = {(num1%num2):.0f}") 38 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/FruitShop.py: -------------------------------------------------------------------------------- 1 | fruit = input() 2 | day = input() 3 | quantity = float(input()) 4 | price = 0.0 5 | mistake = False 6 | if day == "Monday" or day == "Tuesday" or day == "Wednesday" or day == "Thursday" or day == "Friday": 7 | if fruit == "banana": 8 | price = 2.5 9 | elif fruit == "apple": 10 | price = 1.2 11 | elif fruit == "orange": 12 | price = 0.85 13 | elif fruit == "grapefruit": 14 | price = 1.45 15 | elif fruit == "kiwi": 16 | price = 2.7 17 | elif fruit == "pineapple": 18 | price = 5.5 19 | elif fruit == "grapes": 20 | price = 3.85 21 | else: 22 | mistake = True 23 | elif day == "Saturday" or day == "Sunday": 24 | if fruit == "banana": 25 | price = 2.7 26 | elif fruit == "apple": 27 | price = 1.25 28 | elif fruit == "orange": 29 | price = 0.9 30 | elif fruit == "grapefruit": 31 | price = 1.6 32 | elif fruit == "kiwi": 33 | price = 3.0 34 | elif fruit == "pineapple": 35 | price = 5.6 36 | elif fruit == "grapes": 37 | price = 4.2 38 | else: 39 | mistake = True 40 | else: 41 | mistake = True 42 | if not mistake: 43 | print(f"{'{:.2f}'.format(quantity * price)}") 44 | else: 45 | print("error") 46 | 47 | -------------------------------------------------------------------------------- /_05_ConditionalStatementsAdvanced_Lab/TradeComissions.py: -------------------------------------------------------------------------------- 1 | city = input() 2 | amount = float(input()) 3 | isThereAnError = False 4 | commission = 0 5 | if city == "Sofia": 6 | if 0 <= amount <= 500: 7 | commission = amount * 0.05 8 | elif 500 < amount <= 1000: 9 | commission = amount * 0.07 10 | elif 1000 < amount <= 10000: 11 | commission = amount * 0.08 12 | elif amount > 10000: 13 | commission = amount * 0.12 14 | else: 15 | isThereAnError = True 16 | elif city == "Varna": 17 | if 0 <= amount <= 500: 18 | commission = amount * 0.045 19 | elif 500 < amount <= 1000: 20 | commission = amount * 0.075 21 | elif 1000 < amount <= 10000: 22 | commission = amount * 0.10 23 | elif amount > 10000: 24 | commission = amount * 0.13 25 | else: 26 | isThereAnError = True 27 | elif city == "Plovdiv": 28 | if 0 <= amount <= 500: 29 | commission = amount * 0.055 30 | elif 500 < amount <= 1000: 31 | commission = amount * 0.08 32 | elif 1000 < amount <= 10000: 33 | commission = amount * 0.12 34 | elif amount > 10000: 35 | commission = amount * 0.145 36 | else: 37 | isThereAnError = True 38 | else: 39 | isThereAnError = True 40 | if isThereAnError: 41 | print("error") 42 | else: 43 | print(f"{'{:.2f}'.format(commission)}") 44 | -------------------------------------------------------------------------------- /_06_ConditionalStatementsExercise/OnTimeForTheExam.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | hour_of_Exam = int(input()) 4 | minute_of_Exam = int(input()) 5 | hour_of_Arrival = int(input()) 6 | minute_of_Arrival = int(input()) 7 | 8 | total_minutes_Exam = (hour_of_Exam * 60) + minute_of_Exam 9 | total_minutes_Arrival = (hour_of_Arrival * 60) + minute_of_Arrival 10 | difference = abs(total_minutes_Arrival - total_minutes_Exam) 11 | 12 | if total_minutes_Arrival == total_minutes_Exam: 13 | print("On time") 14 | elif total_minutes_Arrival > total_minutes_Exam: 15 | print("Late ") 16 | if total_minutes_Arrival < (total_minutes_Exam + 60): 17 | print(f"{difference:.0f} minutes after the start") 18 | else: 19 | if difference % 60 > 9: 20 | print(f"{math.floor(difference/60)}:{difference % 60} hours after the start") 21 | else: 22 | print(f"{math.floor(difference/60)}:0{difference % 60} hours after the start") 23 | elif total_minutes_Arrival < total_minutes_Exam: 24 | if difference <= 30: 25 | print(f"On time {difference:.0f} minutes before the start") 26 | else: 27 | print("Early ") 28 | if 30 < difference < 60: 29 | print(f"{difference:.0f} minutes before the start") 30 | elif difference >= 60: 31 | if difference % 60 > 9: 32 | print(f"{math.floor(difference/60)}:{difference % 60} hours before the start") 33 | else: 34 | print(f"{math.floor(difference/60)}:0{difference % 60} hours before the start") 35 | --------------------------------------------------------------------------------