├── .gitignore
├── Conditional Statements - Exercise
├── 01. Sum Seconds.py
├── 01. Sum Seconds_Problems_Descriptions.docx
├── 02. Bonus Score.py
├── 03. Time + 15 Minutes.py
├── 04. Toy Shop.py
├── 05. Godzilla vs. Kong.py
├── 06. World Swimming Record.py
├── 07. Shopping.py
└── 08. Lunch Break.py
├── Conditional Statements - Lab
├── .idea
│ ├── .gitignore
│ ├── Conditional Statements - Lab.iml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ └── modules.xml
├── 01. Excellent Result.py
├── 01. Excellent Result_Problems_Descriptions.docx
├── 02. Greater Number.py
├── 03. Even or Odd.py
├── 04. Password Guess.py
├── 05. Number 100 - 200.py
├── 06. Speed Info.py
├── 07. Area of Figures.py
└── main.py
├── Conditional Statements Advanced - Lab
├── 01. Day of Week.py
├── 01. Day of Week_Problems_Description.docx
├── 02. Weekend or Working Day.py
├── 03. Animal Type.py
├── 04. Personal Titles.py
├── 05. Small Shop.py
├── 06. Number in Range.py
├── 07.Working Hours.py
├── 08.Cinema Ticket.py
├── 09. Fruit or Vegetable.py
├── 10. Invalid Number.py
├── 11. Fruit Shop.py
└── 12. Trade Commissions.py
├── First Steps in Coding - Exercise
├── .idea
│ ├── .gitignore
│ ├── First Steps in Coding - Exercise.iml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ └── modules.xml
├── 01. USD to BGN.py
├── 01. USD to BGN_Problem_Description.docx
├── 02. Radians to Degrees.py
├── 03. Deposit Calculator.py
├── 04. Vacation books list.py
├── 05. Supplies for School.py
├── 06. Repainting.py
├── 07. Food Delivery.py
├── 08. Basketball Equipment.py
├── 09. Fish Tank.py
└── main.py
├── First Steps in Coding - Lab
├── .idea
│ ├── .gitignore
│ ├── First Steps in Coding - Lab.iml
│ ├── inspectionProfiles
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ └── modules.xml
├── 01. Hello SoftUni.docx
├── 01. Hello SoftUni.py
├── 02. Nums 1...10.py
├── 03. Rectangle Area.py
├── 04. Inches to Centimeters.py
├── 05. Greeting by Name.py
├── 06. Concatenate Data.py
├── 07. Projects Creation.py
├── 08. Pet Shop.py
└── 09. Yard Greening.py
├── For Loop - Exercise
├── 01. Numbers Ending in 7.py
├── 01. Numbers Ending in 7_Problems_Description.docx
├── 02. Half Sum Element.py
├── 03. Histogram.py
├── 04. Clever Lily.py
├── 05. Salary.py
├── 06. Oscars.py
├── 07. Trekking Mania.py
└── 08. Tennis Ranklist.py
├── For Loop - Lab
├── 01. Numbers from 1 to 100.py
├── 01. Numbers from 1 to 100_Problems_Description.docx
├── 02. Numbers 1...N with Step 3.py
├── 03. Even Powers of 2.py
├── 04. Numbers N...1.py
├── 05. Character Sequence.py
├── 06. Vowels Sum.py
├── 07. Sum Numbers.py
├── 08. Number sequence.py
├── 09. Left and Right Sum.py
└── 10. Odd Even Sum.py
├── Nested Loops - Exercise
├── 01. Number Pyramid.py
├── 01. Number Pyramid_Problems_Description.docx
├── 02. Equal Sums Even Odd Position.py
├── 03. Sum Prime Non Prime.py
├── 04. Train The Trainers.py
├── 05. Special Numbers.py
└── 06. Cinema Tickets.py
├── Nested Loops - Lab
├── 01. Clock.py
├── 01. Clock_Problems_Descriptions.docx
├── 02. Multiplication Table.py
├── 03. Combinations.py
├── 04. Sum of Two Numbers.py
├── 05. Travelling.py
└── 06. Building.py
├── README.md
├── While Loop - Exercise
├── 01. Old Books.py
├── 01. Old Books_Problems_Descriptions.docx
├── 02. Exam Preparation.py
├── 03. Vacation.py
├── 04. Walking.py
├── 05. Coins.py
├── 06. Cake.py
└── 07. Moving.py
└── While Loop - Lab
├── 01. Read Text.py
├── 01. Read Text_Problems_Description.docx
├── 02. Password.py
├── 03. Sum Numbers.py
├── 04. Sequence 2k+1.py
├── 05. Account Balance.py
├── 06. Max Number.py
├── 07. Min Number.py
└── 08. Graduation.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/01. Sum Seconds.py:
--------------------------------------------------------------------------------
1 | import datetime
2 |
3 | time_first = int(input())
4 | time_second = int(input())
5 | time_third = int(input())
6 |
7 | conversion = str(datetime.timedelta(seconds=time_first + time_second + time_third))
8 | print(conversion[3:])
9 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/01. Sum Seconds_Problems_Descriptions.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/Conditional Statements - Exercise/01. Sum Seconds_Problems_Descriptions.docx
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/02. Bonus Score.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | bonuses = {
4 | "100": 5,
5 | "over 100": 0.20,
6 | "over 1000": 0.10,
7 | "even": 1,
8 | "end on 5": 2
9 | }
10 | check_in_end_on_five = str(number)
11 |
12 | if number <= 100:
13 | if (number % 2) == 0:
14 | bonus = bonuses["100"] + bonuses["even"]
15 | total = number + bonus
16 | elif check_in_end_on_five[-1] == "5":
17 | bonus = bonuses["end on 5"] + bonuses["100"]
18 | total = number + bonus
19 | else:
20 | bonus = bonuses["100"]
21 | total = number + bonus
22 | elif number in range(100, 1000):
23 | if (number % 2) == 0:
24 | bonus = bonuses["over 100"] * number + bonuses["even"]
25 | total = number + bonus
26 | elif check_in_end_on_five[-1] == "5":
27 | bonus = bonuses["end on 5"] + bonuses["over 100"] * number
28 | total = number + bonus
29 | else:
30 | bonus = bonuses["over 100"] * number
31 | total = number + bonus
32 | elif number > 1000:
33 | if (number % 2) == 0:
34 | bonus = bonuses["over 1000"] * number + + bonuses["even"]
35 | total = number + bonus
36 | elif check_in_end_on_five[-1] == "5":
37 | bonus = bonuses["end on 5"] + bonuses["over 1000"] * number
38 | total = number + bonus
39 | else:
40 | bonus = bonuses["over 1000"] * number
41 | total = number + bonus
42 |
43 | print(f"{bonus}\n{total}")
44 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/03. Time + 15 Minutes.py:
--------------------------------------------------------------------------------
1 | hours = int(input())
2 | minutes = int(input())
3 |
4 | minutes_added = 15
5 | total_minutes = minutes_added + minutes
6 |
7 | if total_minutes > 59:
8 | over_sixty_minutes = total_minutes - 60
9 | total_time = hours + 1
10 | if total_time >= 24:
11 | total_time = 0
12 | if over_sixty_minutes < 10:
13 | print(f"{total_time}:0{over_sixty_minutes}")
14 | else:
15 | print(f"{total_time}:{over_sixty_minutes}")
16 | else:
17 | if over_sixty_minutes < 10:
18 | print(f"{total_time}:0{over_sixty_minutes}")
19 | else:
20 | print(f"{total_time}:{over_sixty_minutes}")
21 | total_minutes = minutes_added + minutes
22 | elif total_minutes < 10:
23 | print(f"{hours}:0{total_minutes}")
24 | else:
25 | print(f"{hours}:{total_minutes}")
26 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/04. Toy Shop.py:
--------------------------------------------------------------------------------
1 | holiday_price = float(input())
2 | puzzels = int(input())
3 | talking_dols = int(input())
4 | tedy_bears = int(input())
5 | minions = int(input())
6 | trucks = int(input())
7 |
8 | magazine = {
9 | "puzzels": 2.60,
10 | "talking_dols": 3,
11 | "tedy_bears": 4.10,
12 | "minions": 8.20,
13 | "trucks": 2,
14 | "price_off": 0.25,
15 | "rent": 0.10
16 | }
17 |
18 | toys_total_price = magazine["puzzels"] * puzzels + magazine["talking_dols"] * talking_dols + magazine[
19 | "tedy_bears"] * tedy_bears \
20 | + magazine["minions"] * minions + magazine["trucks"] * trucks
21 | toys_count = puzzels + talking_dols + tedy_bears + minions + trucks
22 | if toys_count >= 50:
23 | toys_total_price = toys_total_price - (toys_total_price * magazine["price_off"])
24 | magazine_rent = toys_total_price * magazine["rent"]
25 | magazine_winning = toys_total_price - magazine_rent
26 | if magazine_winning >= holiday_price:
27 | magazine_winning += - holiday_price
28 | print(f"Yes! {magazine_winning:.2f} lv left.")
29 | else:
30 | magazine_winning = holiday_price - magazine_winning
31 | print(f"Not enough money! {magazine_winning:.2f} lv needed.")
32 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/05. Godzilla vs. Kong.py:
--------------------------------------------------------------------------------
1 | film_budget = float(input())
2 | count_extras = int(input())
3 | price_per_one_extra = float(input())
4 |
5 | decorator_expenses = film_budget * 0.10
6 | extras_over_onehundred_off = 0.10
7 | if count_extras > 150:
8 | gear_for_extras = count_extras * price_per_one_extra
9 | gear_for_extras = gear_for_extras - (gear_for_extras * extras_over_onehundred_off)
10 | else:
11 | gear_for_extras = count_extras * price_per_one_extra
12 |
13 | gear_for_extras += decorator_expenses
14 |
15 | if film_budget >= gear_for_extras:
16 | total_movie_cost = film_budget - gear_for_extras
17 | print(f"Action!\nWingard starts filming with {total_movie_cost:.2f} leva left.")
18 | else:
19 | total_movie_cost = gear_for_extras - film_budget
20 | print(f"Not enough money!\nWingard needs {total_movie_cost:.2f} leva more.")
21 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/06. World Swimming Record.py:
--------------------------------------------------------------------------------
1 | import math
2 | record = float(input())
3 | distance_meters = float(input())
4 | time_in_sec_per_meter = float(input())
5 |
6 | slowing_time_per_fifthen_meter = 12.5
7 | slowing_time_meters = 15
8 | distance_need_to_swim = distance_meters * time_in_sec_per_meter
9 | slowing_time = math.floor(distance_meters / slowing_time_meters) * slowing_time_per_fifthen_meter
10 | # slowing_time = slowing_time * slowing_time_per_fifthen_meter
11 | total_time = distance_need_to_swim + slowing_time
12 |
13 | if record > total_time:
14 | print(f" Yes, he succeeded! The new world record is {total_time:.2f} seconds.")
15 | else:
16 | total_time = total_time - record
17 | print(f"No, he failed! He was {total_time:.2f} seconds slower.")
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/07. Shopping.py:
--------------------------------------------------------------------------------
1 | budget = float(input())
2 | video_cards = int(input())
3 | procesors = int(input())
4 | ram_memory = int(input())
5 |
6 | video_cards_off = 0.15
7 | video_cards_price_per_unit = 250
8 | procesors_off = 0.35
9 | ram_memory_off = 0.10
10 | video_cards_total = video_cards * video_cards_price_per_unit
11 | procesors_price = (video_cards_total * procesors_off) * procesors
12 | ram_memory_price = (video_cards_total * ram_memory_off) * ram_memory
13 | total_order_price = video_cards_total + procesors_price + ram_memory_price
14 |
15 | if budget >= total_order_price:
16 | if video_cards > procesors:
17 | total_order_price += - total_order_price * video_cards_off
18 | total_order_price = budget - total_order_price
19 | print(f"You have {total_order_price:.2f} leva left!")
20 | else:
21 | total_order_price = budget - total_order_price
22 | print(f"You have {total_order_price:.2f} leva left!")
23 | else:
24 | if video_cards > procesors:
25 | total_order_price += - total_order_price * video_cards_off
26 | total_order_price = total_order_price - budget
27 | print(f"Not enough money! You need {total_order_price:.2f} leva more!")
28 | else:
29 | total_order_price = total_order_price - budget
30 | print(f"Not enough money! You need {total_order_price:.2f} leva more!")
31 |
--------------------------------------------------------------------------------
/Conditional Statements - Exercise/08. Lunch Break.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | name_serial = input()
4 | serial_len = int(input())
5 | break_time = int(input())
6 |
7 | time_for_lunch = break_time * 1 / 8
8 | time_for_rest = break_time * 1 / 4
9 | time_left = break_time - time_for_lunch - time_for_rest
10 |
11 | if serial_len <= time_left:
12 | time_left = time_left - serial_len
13 | print(f"You have enough time to watch {name_serial} "
14 | f"and left with {math.ceil(time_left)} minutes free time.")
15 | else:
16 | time_left = serial_len - time_left
17 | print(f"You don't have enough time to watch {name_serial}, "
18 | f"you need {math.ceil(time_left)} more minutes.")
19 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/.idea/Conditional Statements - Lab.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/01. Excellent Result.py:
--------------------------------------------------------------------------------
1 | grade = float(input())
2 |
3 | if grade >= 5.50:
4 | print('Excellent!')
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/01. Excellent Result_Problems_Descriptions.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/Conditional Statements - Lab/01. Excellent Result_Problems_Descriptions.docx
--------------------------------------------------------------------------------
/Conditional Statements - Lab/02. Greater Number.py:
--------------------------------------------------------------------------------
1 | firstNumber = int(input())
2 |
3 | secondNumber = int(input())
4 |
5 | if firstNumber > secondNumber:
6 |
7 | print(firstNumber)
8 |
9 | else:
10 |
11 | print(secondNumber)
12 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/03. Even or Odd.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | if number % 2 == 0:
4 | print("even")
5 |
6 | else:
7 |
8 | print("odd")
9 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/04. Password Guess.py:
--------------------------------------------------------------------------------
1 | password = input()
2 |
3 | if password == 's3cr3t!P@ssw0rd':
4 | print('Welcome')
5 |
6 | else:
7 |
8 | print('Wrong password!')
9 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/05. Number 100 - 200.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | if number < 100:
4 |
5 | print('Less than 100')
6 |
7 | elif number >= 100 and number <= 200:
8 |
9 | print("Between 100 and 200")
10 |
11 | elif number > 200:
12 |
13 | print("Greater than 200")
14 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/06. Speed Info.py:
--------------------------------------------------------------------------------
1 | number = float(input())
2 |
3 | if number <= 10:
4 |
5 | print("slow")
6 |
7 | elif number > 10 and number <= 50:
8 |
9 | print("average")
10 | elif number > 50 and number <= 150:
11 |
12 | print("fast")
13 | elif number > 150 and number <= 1000:
14 |
15 | print("ultra fast")
16 |
17 | else:
18 | print("extremely fast")
19 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/07. Area of Figures.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | figure_type = input()
4 |
5 | a = float(input())
6 |
7 | area = 0
8 |
9 | if figure_type == "square":
10 |
11 | area = a * a
12 | elif figure_type == "rectangle":
13 |
14 | b = float(input())
15 |
16 | area = a * b
17 |
18 | elif figure_type == "circle":
19 |
20 | area = math.pi * math.pow(a, 2)
21 |
22 | elif figure_type == "triangle":
23 |
24 | height = float(input())
25 |
26 | area = a * height / 2
27 |
28 | if area == int(area):
29 |
30 | print(int(area))
31 |
32 | else:
33 |
34 | print(round(area * 1000) / 1000)
35 |
--------------------------------------------------------------------------------
/Conditional Statements - Lab/main.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/01. Day of Week.py:
--------------------------------------------------------------------------------
1 | days_of_the_week = int(input())
2 |
3 | week = {
4 | 1: "Monday",
5 | 2: "Tuesday",
6 | 3: "Wednesday",
7 | 4: "Thursday",
8 | 5: "Friday",
9 | 6: "Saturday",
10 | 7: "Sunday"
11 | }
12 |
13 | if days_of_the_week in range(1, 8):
14 | print(week[days_of_the_week])
15 | else:
16 | print("Error")
17 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/01. Day of Week_Problems_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/Conditional Statements Advanced - Lab/01. Day of Week_Problems_Description.docx
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/02. Weekend or Working Day.py:
--------------------------------------------------------------------------------
1 | check_what_day_is = input()
2 |
3 |
4 |
5 |
6 | week = {
7 | "Monday": "Working day",
8 | "Tuesday": "Working day",
9 | "Wednesday": "Working day",
10 | "Thursday": "Working day",
11 | "Friday": "Working day",
12 | "Saturday": "Weekend",
13 | "Sunday": "Weekend",
14 |
15 | }
16 |
17 | if check_what_day_is in week:
18 | print(week[check_what_day_is])
19 | else:
20 | print("Error")
21 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/03. Animal Type.py:
--------------------------------------------------------------------------------
1 | animal = input()
2 |
3 | type_anymal = {
4 | "dog": "mammal",
5 | "crocodile": "reptile",
6 | "tortoise": "reptile",
7 | "snake": "reptile"
8 | }
9 |
10 | if animal in type_anymal:
11 | print(type_anymal[animal])
12 | else:
13 | print("unknown")
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/04. Personal Titles.py:
--------------------------------------------------------------------------------
1 | person_age = float(input())
2 | person_sex = input()
3 |
4 | title_check = {
5 | "m under 16": "Master",
6 | "m over 16": "Mr.",
7 | "f under 16": "Miss",
8 | "f over 16": "Ms."
9 | }
10 |
11 | if person_sex == "m":
12 | if person_age < 16:
13 | print(title_check["m under 16"])
14 | else:
15 | print(title_check["m over 16"])
16 | elif person_sex == "f":
17 | if person_age < 16:
18 | print(title_check["f under 16"])
19 | else:
20 | print(title_check["f over 16"])
21 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/05. Small Shop.py:
--------------------------------------------------------------------------------
1 | product = input()
2 | city = input()
3 | quantity = float(input())
4 |
5 | info = {
6 | "coffee": [0.50, 0.40, 0.45],
7 | "water": [0.80, 0.70, 0.70],
8 | "beer": [1.20, 1.15, 1.10],
9 | "sweets": [1.45, 1.30, 1.35],
10 | "peanuts": [1.60, 1.50, 1.55],
11 | "Sofia": 0, "Plovdiv": 1, "Varna": 2,
12 | }
13 |
14 | check_to_pay = info[product][info[city]] * quantity
15 | print(round(check_to_pay, 2))
16 |
17 | # product = input()
18 | # city = input()
19 | # quantity = float(input())
20 | #
21 | # town = {"Sofia": {
22 | # "coffee": 0.50,
23 | # "water": 0.80,
24 | # "beer": 1.20,
25 | # "sweets": 1.45,
26 | # "peanuts": 1.60},
27 | #
28 | # "Plovdiv": {
29 | # "coffee": 0.40,
30 | # "water": 0.70,
31 | # "beer": 1.15,
32 | # "sweets": 1.30,
33 | # "peanuts": 1.50},
34 | #
35 | # "Varna": {
36 | # "coffee": 0.45,
37 | # "water": 0.70,
38 | # "beer": 1.10,
39 | # "sweets": 1.35,
40 | # "peanuts": 1.55
41 | # }
42 | # }
43 | #
44 | # check_to_pay = town[city][product] * quantity
45 | # print(round(check_to_pay, 2))
46 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/06. Number in Range.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | if number == 0:
4 | print("No")
5 | elif number in range(-100, 101):
6 | print("Yes")
7 | else:
8 | print("No")
9 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/07.Working Hours.py:
--------------------------------------------------------------------------------
1 | hour = int(input())
2 | day = input()
3 |
4 | if 10 <= hour <= 18 and day != "Sunday":
5 | print("open")
6 | else:
7 | print("closed")
8 |
9 |
10 |
11 |
12 | #
13 | #
14 | # hour = int(input())
15 | # day_of_the_week = input()
16 | #
17 | # week = {
18 | # "Monday": "open",
19 | # "Tuesday": "open",
20 | # "Wednesday": "open",
21 | # "Thursday": "open",
22 | # "Friday": "open",
23 | # "Saturday": "open",
24 | # "Sunday": "closed"
25 | # }
26 | #
27 | # if hour in range(10, 19):
28 | # print(week[day_of_the_week])
29 | # else:
30 | # print(week["Sunday"])
31 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/08.Cinema Ticket.py:
--------------------------------------------------------------------------------
1 | day_of_the_week = input()
2 |
3 | week = {
4 | "Monday": 12,
5 | "Tuesday": 12,
6 | "Wednesday": 14,
7 | "Thursday": 14,
8 | "Friday": 12,
9 | "Saturday": 16,
10 | "Sunday": 16
11 | }
12 |
13 | print(week[day_of_the_week])
14 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/09. Fruit or Vegetable.py:
--------------------------------------------------------------------------------
1 | product_name = input()
2 |
3 | check_product = {
4 | "banana": "fruit",
5 | "apple": "fruit",
6 | "kiwi": "fruit",
7 | "cherry": "fruit",
8 | "lemon": "fruit",
9 | "grapes": "fruit",
10 | "tomato": "vegetable",
11 | "cucumber": "vegetable",
12 | "pepper": "vegetable",
13 | "carrot": "vegetable"
14 | }
15 |
16 | if product_name in check_product:
17 | print(check_product[product_name])
18 | else:
19 | print("unknown")
20 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/10. Invalid Number.py:
--------------------------------------------------------------------------------
1 | number_check = int(input())
2 |
3 | if number_check == 0:
4 | print("")
5 | elif number_check not in range(100, 201):
6 | print("invalid")
7 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/11. Fruit Shop.py:
--------------------------------------------------------------------------------
1 | fruit = input()
2 | day_of_week = input()
3 | quantity = float(input())
4 |
5 | banana_price = 2.50
6 | apple_price = 1.20
7 | orange_price = 0.85
8 | grapefruit_price = 1.45
9 | kiwi_price = 2.70
10 | pineapple_price = 5.50
11 | grapes_price = 3.85
12 | price = 0
13 |
14 |
15 | if day_of_week != "Monday" and day_of_week != "Tuesday" and day_of_week != "Wednesday" and \
16 | day_of_week != "Thursday" and day_of_week != "Friday" and day_of_week != "Saturday" \
17 | and day_of_week != "Sunday" or fruit != 'banana' and fruit != 'apple' and fruit != 'grapefruit' \
18 | and fruit != 'kiwi' and fruit != 'grapes' and fruit != 'orange' and fruit != 'pineapple':
19 | print('error')
20 | else:
21 | if day_of_week == 'Sunday' or day_of_week == 'Saturday':
22 | banana_price = 2.70
23 | apple_price = 1.25
24 | orange_price = 0.90
25 | grapefruit_price = 1.60
26 | kiwi_price = 3.00
27 | pineapple_price = 5.60
28 | grapes_price = 4.20
29 |
30 | if fruit == 'banana':
31 | price = banana_price
32 |
33 | elif fruit == 'apple':
34 | price = apple_price
35 |
36 | elif fruit == 'grapefruit':
37 | price = grapefruit_price
38 |
39 | elif fruit == 'kiwi':
40 | price = kiwi_price
41 |
42 | elif fruit == 'grapes':
43 | price = grapes_price
44 |
45 | elif fruit == 'orange':
46 | price = orange_price
47 |
48 | elif fruit == 'pineapple':
49 | price = pineapple_price
50 | total_price = quantity * price
51 | print(f'{total_price:.2f}')
52 |
53 |
54 | #
55 | #
56 | #
57 | #
58 | #
59 | #
60 | # type_food = input()
61 | # days_of_the_week = input()
62 | # quantity = float(input())
63 | #
64 | # prices = {
65 | # "banana": [2.50, 2.70],
66 | # "apple": [1.20, 1.25],
67 | # "orange": [0.85, 0.90],
68 | # "grapefruit": [1.45, 1.60],
69 | # "kiwi": [2.70, 3.00],
70 | # "pineapple": [5.50, 5.60],
71 | # "grapes": [3.85, 4.20],
72 | # "weekend": 1,
73 | # "week": 0}
74 | #
75 | #
76 | # day_check = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
77 | # if days_of_the_week in day_check and type_food in prices:
78 | # if days_of_the_week in day_check[:5]:
79 | # total = prices[type_food][prices["week"]] * quantity
80 | # else:
81 | # total = prices[type_food][prices["weekend"]] * quantity
82 | # print(f"{total:.2f}")
83 | # else:
84 | # print("error")
85 |
--------------------------------------------------------------------------------
/Conditional Statements Advanced - Lab/12. Trade Commissions.py:
--------------------------------------------------------------------------------
1 | town_name = input()
2 | sales = float(input())
3 |
4 | commisions_town = {"Sofia": {
5 | "500": 0.05,
6 | "over 500 - 1000": 0.07,
7 | "1000 - 10000": 0.08,
8 | "over 10000": 0.12, },
9 | "Varna": {
10 | "500": 0.045,
11 | "over 500 - 1000": 0.075,
12 | "1000 - 10000": 0.10,
13 | "over 10000": 0.13, },
14 | "Plovdiv": {
15 | "500": 0.055,
16 | "over 500 - 1000": 0.08,
17 | "1000 - 10000": 0.12,
18 | "over 10000": 0.145, }
19 | }
20 |
21 | if town_name in commisions_town and sales > 0:
22 | if 0 <= sales <= 500:
23 | total_sales = commisions_town[town_name]["500"] * sales
24 | elif 500 < sales <= 1000:
25 | total_sales = commisions_town[town_name]["over 500 - 1000"] * sales
26 | elif 1000 < sales <= 10000:
27 | total_sales = commisions_town[town_name]["1000 - 10000"] * sales
28 | elif sales > 10000:
29 | total_sales = commisions_town[town_name]["over 10000"] * sales
30 | print("{:.2f}".format((total_sales)))
31 |
32 | else:
33 | print("error")
34 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/.idea/First Steps in Coding - Exercise.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/01. USD to BGN.py:
--------------------------------------------------------------------------------
1 | input_number = float(input())
2 |
3 | result = input_number * 1.79549
4 |
5 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/01. USD to BGN_Problem_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/First Steps in Coding - Exercise/01. USD to BGN_Problem_Description.docx
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/02. Radians to Degrees.py:
--------------------------------------------------------------------------------
1 | from math import pi
2 |
3 | radians_input = float(input())
4 |
5 | degrees = radians_input * 180 / pi
6 |
7 | print(degrees)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/03. Deposit Calculator.py:
--------------------------------------------------------------------------------
1 | deposit_sum = float(input())
2 |
3 | term_for_deposit = int(input())
4 |
5 | percentage = float(input())
6 |
7 | increase = deposit_sum * percentage / 100.0
8 |
9 | increase_in_a_month = increase / 12
10 |
11 | result = deposit_sum + term_for_deposit * increase_in_a_month
12 |
13 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/04. Vacation books list.py:
--------------------------------------------------------------------------------
1 | count_of_pages = int(input())
2 |
3 | pages_an_hour = int(input())
4 |
5 | days_needed = int(input())
6 |
7 | result = int((count_of_pages / pages_an_hour) / days_needed)
8 |
9 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/05. Supplies for School.py:
--------------------------------------------------------------------------------
1 | count_of_pens = int(input()) * 5.80
2 |
3 | count_of_markers= int(input()) * 7.20
4 |
5 | count_of_cleaners = int(input()) * 1.20
6 |
7 | percentage = float(input())
8 |
9 | sum_of_all_products = count_of_markers + count_of_cleaners + count_of_pens
10 |
11 | result = sum_of_all_products - (sum_of_all_products * percentage / 100)
12 |
13 | print(result)
14 |
15 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/06. Repainting.py:
--------------------------------------------------------------------------------
1 | nylon = int(input())
2 |
3 | paint = int(input())
4 |
5 | paintThinner = int(input())
6 |
7 | workersHours = int(input())
8 |
9 | nylonSum = float(nylon + 2) * 1.50
10 |
11 | paintPercentage = float(paint * 0.10)
12 |
13 | paintSum = float(paint + paintPercentage) * 14.50
14 |
15 | paintThinnerSum = paintThinner * 5.00
16 |
17 | everythingSum = nylonSum + paintSum + paintThinnerSum + 0.40
18 |
19 | workersHoursSum = (everythingSum * 0.30) * workersHours
20 |
21 | result = everythingSum + workersHoursSum
22 |
23 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/07. Food Delivery.py:
--------------------------------------------------------------------------------
1 | chicken = int(input())
2 |
3 | fish = int(input())
4 |
5 | vegan = int(input())
6 |
7 | chickenPrice = chicken * 10.35
8 |
9 | fishPrice = fish * 12.40
10 |
11 | veganDishPrice = vegan * 8.15
12 |
13 | sumOfAllDishes = chickenPrice + fishPrice + veganDishPrice
14 |
15 | discount = sumOfAllDishes * 0.2
16 |
17 | result = sumOfAllDishes + discount + 2.50
18 |
19 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/08. Basketball Equipment.py:
--------------------------------------------------------------------------------
1 | tax = float(input())
2 |
3 | shoes_price = tax - tax * (40 / 100.0)
4 |
5 | training_kit = shoes_price - shoes_price * (20 / 100.0)
6 |
7 | ball = training_kit / 4
8 |
9 | basketball_accessories = ball / 5
10 |
11 | result = tax + shoes_price + training_kit + basketball_accessories + ball
12 |
13 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/09. Fish Tank.py:
--------------------------------------------------------------------------------
1 | lenght = float(input())
2 |
3 | width = float(input())
4 |
5 | height = float(input())
6 |
7 | percentage = float(input())
8 |
9 | volume = lenght * width * height
10 |
11 | volumeInLiters = volume / 1000
12 |
13 | busy = percentage / 100
14 |
15 | liters = volumeInLiters * (1 - busy)
16 |
17 | print(liters)
18 |
--------------------------------------------------------------------------------
/First Steps in Coding - Exercise/main.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/.idea/First Steps in Coding - Lab.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/01. Hello SoftUni.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/First Steps in Coding - Lab/01. Hello SoftUni.docx
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/01. Hello SoftUni.py:
--------------------------------------------------------------------------------
1 | message = 'Hello SoftUni'
2 | print(message)
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/02. Nums 1...10.py:
--------------------------------------------------------------------------------
1 | i = 0
2 |
3 | while i < 10:
4 | i += 1
5 | print(i)
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/03. Rectangle Area.py:
--------------------------------------------------------------------------------
1 | side_a = int(input())
2 |
3 | side_b = int(input())
4 |
5 | result = side_a * side_b
6 |
7 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/04. Inches to Centimeters.py:
--------------------------------------------------------------------------------
1 | inch_input = float(input())
2 |
3 | result = inch_input * 2.54
4 |
5 | print(result)
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/05. Greeting by Name.py:
--------------------------------------------------------------------------------
1 | name_input = str(input())
2 |
3 | print(f'Hello, {name_input}!')
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/06. Concatenate Data.py:
--------------------------------------------------------------------------------
1 | first_name = str(input())
2 |
3 | last_name = str(input())
4 |
5 | age = int(input())
6 |
7 | town_name = str(input())
8 |
9 |
10 | print(f'You are {first_name} {last_name}, a {age}-years old person from {town_name}.')
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/07. Projects Creation.py:
--------------------------------------------------------------------------------
1 | architect_name = str(input())
2 |
3 | count_of_projects = int(input())
4 |
5 | time_needed_for_one_project = 3
6 |
7 | result = count_of_projects * time_needed_for_one_project
8 |
9 | print(f'The architect {architect_name} will need {result} hours to complete {count_of_projects} project/s.')
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/08. Pet Shop.py:
--------------------------------------------------------------------------------
1 | dog_food_amount = int(input())
2 |
3 | cat_food_amount = int(input())
4 |
5 | cat_food_price = 4
6 |
7 | dog_food_price = 2.50
8 |
9 | sum_of_both_foods = float((cat_food_amount * cat_food_price) + (dog_food_amount * dog_food_price))
10 |
11 | print(f'{sum_of_both_foods} lv.')
12 |
--------------------------------------------------------------------------------
/First Steps in Coding - Lab/09. Yard Greening.py:
--------------------------------------------------------------------------------
1 | square_meters_to_be_landscaped = float(input())
2 |
3 | square_meter_price = square_meters_to_be_landscaped * 7.61
4 |
5 | discount_result = square_meter_price * 0.18
6 |
7 | print(f'The final price is: {square_meter_price - discount_result} lv.\nThe discount is: {discount_result} lv.')
--------------------------------------------------------------------------------
/For Loop - Exercise/01. Numbers Ending in 7.py:
--------------------------------------------------------------------------------
1 | for num in range(1, 1001):
2 | if num % 10 == 7:
3 | print(num)
--------------------------------------------------------------------------------
/For Loop - Exercise/01. Numbers Ending in 7_Problems_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/For Loop - Exercise/01. Numbers Ending in 7_Problems_Description.docx
--------------------------------------------------------------------------------
/For Loop - Exercise/02. Half Sum Element.py:
--------------------------------------------------------------------------------
1 | numbers_to_enter = int(input())
2 |
3 | numbers_input = list()
4 |
5 | for i in range(numbers_to_enter):
6 | numbers_input.append(int(input()))
7 |
8 | numbers_input.sort()
9 | sum_of_all_numbers = sum(numbers_input) - numbers_input[-1]
10 | difrenc_numbers = numbers_input[-1] - (sum(numbers_input) - numbers_input[-1])
11 | if numbers_input[-1] == sum_of_all_numbers:
12 | print(f"Yes\nSum = {numbers_input[-1]}")
13 | else:
14 | print(f"No\nDiff = {abs(difrenc_numbers)}")
15 |
--------------------------------------------------------------------------------
/For Loop - Exercise/03. Histogram.py:
--------------------------------------------------------------------------------
1 | number_to_check = int(input())
2 |
3 | percent_under_numbers = {
4 | "under 200": 0,
5 | "200 - 399": 0,
6 | "400 - 599": 0,
7 | "600 - 799": 0,
8 | "over 800": 0
9 | }
10 |
11 | for _ in range(0, number_to_check):
12 | number = int(input())
13 | if number in range(0, 200):
14 | percent_under_numbers["under 200"] += 1
15 | elif number in range(200, 400):
16 | percent_under_numbers["200 - 399"] += 1
17 | elif number in range(400, 600):
18 | percent_under_numbers["400 - 599"] += 1
19 | elif number in range(500, 800):
20 | percent_under_numbers["600 - 799"] += 1
21 | elif number >= 800:
22 | percent_under_numbers["over 800"] += 1
23 |
24 | under_twohundred = (percent_under_numbers["under 200"] / number_to_check) * 100
25 | twohundred_fourhundred = (percent_under_numbers["200 - 399"] / number_to_check) * 100
26 | fourhundred_sixhundred = (percent_under_numbers["400 - 599"] / number_to_check) * 100
27 | sixhundred_eithhundred = (percent_under_numbers["600 - 799"] / number_to_check) * 100
28 | over_eithhundred = (percent_under_numbers["over 800"] / number_to_check) * 100
29 |
30 | print("{:.2f}".format(under_twohundred) + "%")
31 | print("{:.2f}".format(twohundred_fourhundred) + "%")
32 | print("{:.2f}".format(fourhundred_sixhundred) + "%")
33 | print("{:.2f}".format(sixhundred_eithhundred) + "%")
34 | print("{:.2f}".format(over_eithhundred) + "%")
35 |
--------------------------------------------------------------------------------
/For Loop - Exercise/04. Clever Lily.py:
--------------------------------------------------------------------------------
1 | lily_age = int(input())
2 | washing_machine_price = float(input())
3 | toy_price = int(input())
4 |
5 | added_money_to_birthday_eve = 0
6 | brother_steal_money = 1
7 | extra_money = 0
8 | gifts_received = -1
9 |
10 | for age in range(0, lily_age + 1):
11 | if age != 0 and (age % 2) == 0:
12 | added_money_to_birthday_eve += 10
13 | extra_money += added_money_to_birthday_eve
14 | else:
15 | gifts_received += 1
16 |
17 | total_brother_steal_money = brother_steal_money * (lily_age - gifts_received)
18 | extra_money = (extra_money + (gifts_received * toy_price)) - total_brother_steal_money
19 |
20 | if extra_money >= washing_machine_price:
21 | extra_money = extra_money - washing_machine_price
22 | print(f"Yes! {extra_money:.2f}")
23 | else:
24 | extra_money = washing_machine_price - extra_money
25 | print(f"No! {extra_money:.2f}")
26 |
--------------------------------------------------------------------------------
/For Loop - Exercise/05. Salary.py:
--------------------------------------------------------------------------------
1 | open_tab_browser = int(input())
2 | salary = int(input())
3 |
4 | salary_info = {"penalty": {
5 | "Facebook": 150,
6 | "Instagram": 100,
7 | "Reddit": 50, },
8 | "tabs counter": {
9 | "Facebook": 0,
10 | "Instagram": 0,
11 | "Reddit": 0}
12 | }
13 | salary_left = salary
14 | tabs_check = ["Facebook", "Instagram", "Reddit"]
15 | no_money_left = False
16 |
17 | for tab in range(0, open_tab_browser):
18 | tab_name = input()
19 | if tab_name in tabs_check:
20 | salary_left = salary_left - salary_info["penalty"][tab_name]
21 | if salary_left <= 0:
22 | no_money_left = True
23 | print("You have lost your salary.")
24 | break
25 |
26 | if no_money_left == False:
27 | if salary_left == salary:
28 | print(salary_left)
29 | else:
30 | print(salary_left)
31 |
--------------------------------------------------------------------------------
/For Loop - Exercise/06. Oscars.py:
--------------------------------------------------------------------------------
1 | actor_name = input()
2 | points_from_academy = float(input())
3 | judges_number = int(input())
4 |
5 | judges_score = points_from_academy
6 | nominated = False
7 |
8 | for judge in range(0, judges_number):
9 | judge_name = input()
10 | judge_points = float(input())
11 | judges_score += (len(judge_name) * (judge_points / 2))
12 | if judges_score > 1250.5:
13 | print(f"Congratulations, {actor_name} got a nominee for leading role with {judges_score:.1f}!")
14 | nominated = True
15 | break
16 |
17 | if nominated == False:
18 | judges_score = 1250.5 - judges_score
19 | print(f"Sorry, {actor_name} you need {judges_score:.1f} more!")
20 |
--------------------------------------------------------------------------------
/For Loop - Exercise/07. Trekking Mania.py:
--------------------------------------------------------------------------------
1 | number_groups = int(input())
2 |
3 | five_people_gorups = 0
4 | six_to_twelve_groups = 0
5 | thirteen_people_gorups = 0
6 | twenty_six_people_groups = 0
7 | over_foutry_one_people_groups = 0
8 | total_people = 0
9 | total_musala = 0
10 | total_monblan = 0
11 | total_kilimandjaro = 0
12 | total_ktwo = 0
13 | total_everest = 0
14 |
15 | for groups in range(0, number_groups):
16 | group = int(input())
17 | total_people += group
18 | if group <= 5:
19 | five_people_gorups += 1
20 | total_musala += group
21 | elif 5 < group <= 12:
22 | six_to_twelve_groups += 1
23 | total_monblan += group
24 | elif 12 < group <= 25:
25 | thirteen_people_gorups += 1
26 | total_kilimandjaro += group
27 | elif 25 < group <= 40:
28 | twenty_six_people_groups += 1
29 | total_ktwo += group
30 | elif group > 40:
31 | over_foutry_one_people_groups += 1
32 | total_everest += group
33 |
34 | musala = total_musala / total_people * 100
35 | monblan = total_monblan / total_people * 100
36 | kilimandjaro = total_kilimandjaro / total_people * 100
37 | ktwo = total_ktwo / total_people * 100
38 | everest = total_everest / total_people * 100
39 |
40 | print(f"{musala:.2f}%\n{monblan:.2f}%\n{kilimandjaro:.2f}%\n{ktwo:.2f}%\n{everest:.2f}%")
41 |
--------------------------------------------------------------------------------
/For Loop - Exercise/08. Tennis Ranklist.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | tournaments_count = int(input())
4 | starting_points = int(input())
5 |
6 | tournament_points = {
7 | "W": 2000,
8 | "F": 1200,
9 | "SF": 720
10 | }
11 | tournament_win_count = 0
12 | total_points = starting_points
13 |
14 | for torunament in range(0, tournaments_count):
15 | tournament_finish = input()
16 | total_points += + tournament_points[tournament_finish]
17 | if tournament_finish == "W":
18 | tournament_win_count += 1
19 |
20 | average_points = (total_points - starting_points) / tournaments_count
21 | tournament_win_percent = (tournament_win_count / tournaments_count) * 100
22 | print(f"Final points: {total_points}")
23 | print(f"Average points: {math.floor(average_points)}")
24 | print(f"{tournament_win_percent:.2f}%")
25 |
--------------------------------------------------------------------------------
/For Loop - Lab/01. Numbers from 1 to 100.py:
--------------------------------------------------------------------------------
1 | for i in range(1, 101):
2 | print(i)
--------------------------------------------------------------------------------
/For Loop - Lab/01. Numbers from 1 to 100_Problems_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/For Loop - Lab/01. Numbers from 1 to 100_Problems_Description.docx
--------------------------------------------------------------------------------
/For Loop - Lab/02. Numbers 1...N with Step 3.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | for i in range(1, number + 1, 3):
4 | print(i)
5 |
--------------------------------------------------------------------------------
/For Loop - Lab/03. Even Powers of 2.py:
--------------------------------------------------------------------------------
1 | n = int(input())
2 |
3 | for i in range(0, n + 1, 2):
4 | print(2 ** i)
5 |
--------------------------------------------------------------------------------
/For Loop - Lab/04. Numbers N...1.py:
--------------------------------------------------------------------------------
1 | number =int(input())
2 |
3 | for i in range (number, 0, -1):
4 | print(i)
--------------------------------------------------------------------------------
/For Loop - Lab/05. Character Sequence.py:
--------------------------------------------------------------------------------
1 | text = input()
2 |
3 | i = 0
4 | for i in text:
5 | print(i)
6 |
7 |
--------------------------------------------------------------------------------
/For Loop - Lab/06. Vowels Sum.py:
--------------------------------------------------------------------------------
1 | text_input = input()
2 |
3 | letters = {
4 | "a": 1,
5 | "e": 2,
6 | "i": 3,
7 | "o": 4,
8 | "u": 5
9 | }
10 | summary = 0
11 | letter_check = ("a", "e", "i", "o" ,"u")
12 | for letter in text_input:
13 | if letter in letter_check:
14 | summary += letters[letter]
15 | print(summary)
--------------------------------------------------------------------------------
/For Loop - Lab/07. Sum Numbers.py:
--------------------------------------------------------------------------------
1 | enter_number = int(input())
2 | numbers = list()
3 | total = 0
4 | for n in range(0, enter_number):
5 | numbers_to_sum = int(input())
6 | numbers.append(numbers_to_sum)
7 |
8 | for _ in numbers:
9 | total += _
10 | print(total)
--------------------------------------------------------------------------------
/For Loop - Lab/08. Number sequence.py:
--------------------------------------------------------------------------------
1 | input_number = int(input())
2 |
3 | numbers = list()
4 | for n in range(0, input_number):
5 | numbers_to_sum = int(input())
6 | numbers.append(numbers_to_sum)
7 |
8 | numbers.sort()
9 | print(f"Max number: {numbers[-1]}\nMin number: {numbers[0]}")
10 |
--------------------------------------------------------------------------------
/For Loop - Lab/09. Left and Right Sum.py:
--------------------------------------------------------------------------------
1 | n = int(input())
2 | left_sum = 0
3 | right_sum = 0
4 | for number in range(0, n*2):
5 | current_num = int(input())
6 | if number < n:
7 | left_sum+=current_num
8 | elif number >=n:
9 | right_sum+=current_num
10 |
11 | if left_sum == right_sum:
12 | print('Yes, sum = ' + str(right_sum))
13 | else:
14 | diff = abs(left_sum-right_sum)
15 | print('No, diff = '+ str(diff))
--------------------------------------------------------------------------------
/For Loop - Lab/10. Odd Even Sum.py:
--------------------------------------------------------------------------------
1 | number_enter = int(input())
2 |
3 | even_number = 0
4 | odd_number = 0
5 | count = 2
6 |
7 | for position in range(number_enter):
8 | number = int(input())
9 | if (position % 2) != 0:
10 | odd_number += number
11 | else:
12 | even_number += number
13 | count += 1
14 |
15 | if even_number == odd_number:
16 | print(f"Yes\nSum = {abs(even_number)}")
17 | else:
18 | total = odd_number - even_number
19 | print(f"No\nDiff = {abs(total)}")
20 |
21 |
22 |
23 |
24 |
25 |
26 | #
27 | #
28 | #
29 | #
30 | #
31 | #
32 | # number_enter = int(input())
33 | #
34 | # numbers = list()
35 | # even_number = 0
36 | # odd_number = 0
37 | # count = 2
38 | #
39 | # for _ in range(number_enter):
40 | # number = int(input())
41 | # numbers.append(number)
42 | # for number_one in numbers:
43 | # if (count % 2) != 0:
44 | # odd_number += number_one
45 | # else:
46 | # even_number += number_one
47 | # count += 1
48 | #
49 | # if even_number == odd_number:
50 | # print(f"Yes\nSum = {abs(even_number)}")
51 | # else:
52 | # total = odd_number - even_number
53 | # print(f"No\nDiff = {abs(total)}")
54 |
--------------------------------------------------------------------------------
/Nested Loops - Exercise/01. Number Pyramid.py:
--------------------------------------------------------------------------------
1 | pyramid_number = int(input())
2 |
3 |
4 | current = 1
5 | is_current_bigger_than_input_number = False
6 |
7 | for row in range(1, pyramid_number + 1):
8 | for col in range(1, row + 1):
9 | if current > pyramid_number:
10 | is_current_bigger_than_input_number = True
11 | break
12 | print(str(current) + " ", end="")
13 | current += 1
14 | if is_current_bigger_than_input_number:
15 | break
16 | print("")
17 |
--------------------------------------------------------------------------------
/Nested Loops - Exercise/01. Number Pyramid_Problems_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/Nested Loops - Exercise/01. Number Pyramid_Problems_Description.docx
--------------------------------------------------------------------------------
/Nested Loops - Exercise/02. Equal Sums Even Odd Position.py:
--------------------------------------------------------------------------------
1 | number_one = int(input())
2 | number_two = int(input())
3 |
4 | for number in range(number_one, number_two + 1):
5 | number_to_str = str(number)
6 | even_sum = 0
7 | odd_sum = 0
8 |
9 | for index, digit in enumerate(number_to_str):
10 | if index % 2 == 0:
11 | even_sum += int(digit)
12 | else:
13 | odd_sum += int(digit)
14 | if even_sum == odd_sum:
15 | print(number, end=" ")
16 |
17 |
18 |
19 | # [print(num, end=" ") for num in range(int(input()), int(input()) + 1) if sum(list(map(int, str(num)))[::2]) == sum(list(map(int, str(num)))[1::2])]
20 |
21 |
22 |
23 |
24 | ###
25 | # number_one = int(input())
26 | # number_two = int(input())
27 | #
28 | # for number in range(number_one, number_two + 1):
29 | # even_sum = 0
30 | # odd_sum = 0
31 | # for i, digit in enumerate(str(number)):
32 | # if i % 2 == 0:
33 | # even_sum += int(digit)
34 | # else:
35 | # odd_sum += int(digit)
36 | # if even_sum == odd_sum:
37 | # print(number, end=" ")
--------------------------------------------------------------------------------
/Nested Loops - Exercise/03. Sum Prime Non Prime.py:
--------------------------------------------------------------------------------
1 |
2 | prime = 0
3 | not_prime = 0
4 | while True:
5 | n = input()
6 | if n == "stop":
7 | break
8 | n = int(n)
9 | if n >= 0:
10 | for i in range(2, n // 2):
11 | if (n % i) == 0:
12 | not_prime += n
13 | break
14 | else:
15 | prime += n
16 |
17 | else:
18 | print("Number is negative.")
19 |
20 |
21 | print(f"Sum of all prime numbers is: {prime}")
22 | print(f"Sum of all non prime numbers is: {not_prime}")
--------------------------------------------------------------------------------
/Nested Loops - Exercise/04. Train The Trainers.py:
--------------------------------------------------------------------------------
1 | judges_count = int(input())
2 |
3 | presentations_info = {}
4 | counter = 0
5 | total_average_score = 0
6 | score_numbers = 0
7 | while True:
8 | presentation_name = input()
9 | if presentation_name == "Finish":
10 | break
11 | presentations_info[presentation_name] = 0
12 | for judge in range(judges_count):
13 | score = float(input())
14 | presentations_info[presentation_name] += score
15 | counter += 1
16 | total_average_score += score
17 | score_numbers += 1
18 | presentations_info[presentation_name] = presentations_info[presentation_name] / counter
19 | counter = 0
20 |
21 | total_average_score = total_average_score / score_numbers
22 | for key, value in presentations_info.items():
23 | print(f"{key} - {value:.2f}.")
24 | print(f"Student's final assessment is {total_average_score:.2f}.")
25 |
--------------------------------------------------------------------------------
/Nested Loops - Exercise/05. Special Numbers.py:
--------------------------------------------------------------------------------
1 | number_to_check = int(input())
2 |
3 |
4 |
5 | for number_one in range(1, 9):
6 | if number_to_check % number_one == 0:
7 |
8 | for number_two in range(1, 9):
9 | if number_to_check % number_two == 0:
10 |
11 | for number_three in range(1, 9):
12 | if number_to_check % number_three == 0:
13 |
14 | for number_four in range(1, 9):
15 | if number_to_check % number_four == 0:
16 | print(f"{number_one}{number_two}{number_three}{number_four}", end=" ")
17 |
18 |
19 |
20 | #
21 | # number_to_check = int(input())
22 | #
23 | # for n in range(1111, 10_000):
24 | # if all(x != "0" and number_to_check % int(x) == 0 for x in str(n)):
25 | # print(n, end=" ")
26 | #
27 | #
28 | #
29 | #
30 |
31 |
32 |
33 |
34 | ###
35 | # n = int(input())
36 | #
37 | # for numbers in range(1111, 10000):
38 | # magic_number_find = True
39 | # for number in str(numbers):
40 | # if any(["0" in str(numbers), n % int(number) != 0]):
41 | # magic_number_find = False
42 | # break
43 | # if magic_number_find:
44 | # print(numbers, end=" ")
45 |
46 | ###
47 |
48 | # n = int(input())
49 | #
50 | # for numbers in range(1111, 10000):
51 | # numbers = str(numbers)
52 | # if "0" not in numbers:
53 | # if all([n % int(numbers[0]) == 0, n % int(numbers[1]) == 0, n % int(numbers[2]) == 0,
54 | # n % int(numbers[3]) == 0]):
55 | # print(numbers, end=" ")
--------------------------------------------------------------------------------
/Nested Loops - Exercise/06. Cinema Tickets.py:
--------------------------------------------------------------------------------
1 | movie_name = input()
2 |
3 | students_tickets = 0
4 | standard_tickets = 0
5 | kids_tickets = 0
6 | total_tickets = 0
7 | while movie_name != "Finish":
8 | tickets_number = int(input())
9 | ticket_type = input()
10 | total = 0
11 | while True:
12 | if ticket_type == "standard":
13 | standard_tickets += 1
14 | elif ticket_type == "kid":
15 | kids_tickets += 1
16 | elif ticket_type == "student":
17 | students_tickets += 1
18 | if ticket_type == "Finish" or total == tickets_number:
19 | print(f"{movie_name} - {((total / tickets_number) * 100):.2f}% full.")
20 | movie_name = ticket_type
21 | break
22 | elif ticket_type == "End":
23 | print(f"{movie_name} - {((total / tickets_number) * 100):.2f}% full.")
24 | movie_name = input()
25 | break
26 |
27 | total += 1
28 | total_tickets += 1
29 | ticket_type = input()
30 |
31 | print(f"Total tickets: {total_tickets}")
32 | print(f"{((students_tickets / total_tickets) * 100):.2f}% student tickets.")
33 | print(f"{((standard_tickets / total_tickets) * 100):.2f}% standard tickets.")
34 | print(f"{((kids_tickets / total_tickets) * 100):.2f}% kids tickets.")
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | # movie_name = input()
45 | # new_name = movie_name
46 | # moive_theater_info = {}
47 | # student_tickets = 0
48 | # standart_tickets = 0
49 | # kids_tickets = 0
50 | # total_tickets = 0
51 | # number_check = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
52 | # data = ""
53 | # while True:
54 | # if data == "Finish":
55 | # break
56 | # data = input()
57 | # if data == "End":
58 | # data = input()
59 | # moive_theater_info[data] = 0
60 | # elif data[0] in number_check:
61 | # number_tickets = int(data)
62 | # moive_theater_info[new_name] = data
63 | # for ticket in range(number_tickets + 1):
64 | # if ticket == number_tickets:
65 | # moive_theater_info[new_name] = (ticket / number_tickets) * 100
66 | # data = input()
67 | # new_name = data
68 | # break
69 | # else:
70 | # ticket_type = input()
71 | # if ticket_type == "Finish":
72 | # data = "Finish"
73 | # moive_theater_info[new_name] = (ticket / number_tickets) * 100
74 | # break
75 | # elif ticket_type == "End":
76 | # moive_theater_info[new_name] = (ticket / number_tickets) * 100
77 | # data = input()
78 | # if data == "Finish":
79 | # break
80 | # else:
81 | # moive_theater_info[data] = 0
82 | # new_name = data
83 | # break
84 | # elif ticket_type == "student":
85 | # student_tickets += 1
86 | #
87 | # elif ticket_type == "standard":
88 | # standart_tickets += 1
89 | # else:
90 | # kids_tickets += 1
91 | #
92 | # total_tickets = standart_tickets + student_tickets + kids_tickets
93 | # total_studend = (student_tickets / total_tickets) * 100
94 | # total_stantard = (standart_tickets / total_tickets) * 100
95 | # total_kid = (kids_tickets / total_tickets) * 100
96 | # for movie, capacity in moive_theater_info.items():
97 | # print(f"{movie} - {capacity:.2f}% full.")
98 | # print(f"Total tickets: {total_tickets}")
99 | # print(f"{total_studend:.2f}% student tickets.")
100 | # print(f"{total_stantard:.2f}% standard tickets.")
101 | # print(f"{total_kid:.2f}% kids tickets.")
102 |
--------------------------------------------------------------------------------
/Nested Loops - Lab/01. Clock.py:
--------------------------------------------------------------------------------
1 | for hours in range(24):
2 | for minutes in range(60):
3 | print(f"{hours}:{minutes}")
--------------------------------------------------------------------------------
/Nested Loops - Lab/01. Clock_Problems_Descriptions.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/Nested Loops - Lab/01. Clock_Problems_Descriptions.docx
--------------------------------------------------------------------------------
/Nested Loops - Lab/02. Multiplication Table.py:
--------------------------------------------------------------------------------
1 | for a in range(1, 11):
2 | for b in range(1, 11):
3 | c = a * b
4 | print(f"{a} * {b} = {c}")
--------------------------------------------------------------------------------
/Nested Loops - Lab/03. Combinations.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | combinations_count = 0
4 |
5 | for x1 in range(0, number + 1):
6 | for x2 in range(0, number + 1):
7 | for x3 in range(0, number + 1):
8 | if x1 + x2 + x3 == number:
9 | combinations_count += 1
10 | print(combinations_count)
11 |
--------------------------------------------------------------------------------
/Nested Loops - Lab/04. Sum of Two Numbers.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 | number_end = int(input())
3 | magic_number = int(input())
4 |
5 | combinations_count = 0
6 | stop = 0
7 |
8 | for x1 in range(number, number_end + 1):
9 | for x2 in range(number, number_end + 1):
10 | if x1 + x2 == magic_number:
11 | combinations_count += 1
12 | total = x1 + x2
13 | stop += 1
14 | print(f"Combination N:{combinations_count} ({x1} + {x2} = {total})")
15 | break
16 | else:
17 | combinations_count += 1
18 | if x1 + x2 == magic_number:
19 | total = x1 + x2
20 | stop += 1
21 | break
22 |
23 | if stop != 2:
24 | print(f"{combinations_count} combinations - neither equals {magic_number}")
25 |
--------------------------------------------------------------------------------
/Nested Loops - Lab/05. Travelling.py:
--------------------------------------------------------------------------------
1 | saved_money = 0
2 |
3 | while True:
4 | destination = input()
5 |
6 | if destination == 'End':
7 | break
8 |
9 | minimum_money = float(input())
10 | saved_money = 0
11 |
12 | while saved_money < minimum_money:
13 | saved = float(input())
14 | saved_money += saved
15 |
16 | print(f'Going to {destination}!')
17 |
18 |
19 |
20 | #
21 | #
22 | #
23 | # destination = input()
24 | # budget = float(input())
25 | #
26 | # destination_name = destination
27 | # going_to_destination = list()
28 | # destination_budget = budget
29 | # destination_save = 0
30 | # checking_for_numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
31 | #
32 | # while True:
33 | # infomation = input()
34 | # if infomation[0] in checking_for_numbers:
35 | # destination_save += float(infomation)
36 | # else:
37 | # if destination_save >= destination_budget:
38 | # going_to_destination.append(destination_name)
39 | # destination_budget = 0
40 | # destination_save = 0
41 | # destination_name = infomation
42 | # if infomation == "End":
43 | # for towns in going_to_destination:
44 | # print(f"Going to {towns}!")
45 | # break
46 | # destination_budget = float(input())
47 |
--------------------------------------------------------------------------------
/Nested Loops - Lab/06. Building.py:
--------------------------------------------------------------------------------
1 | building_floors = int(input())
2 | rooms_per_floors = int(input())
3 |
4 | for floors in range(building_floors, 0, - 1):
5 | for rooms in range(rooms_per_floors):
6 | if floors == building_floors:
7 | print(f"L{floors}{rooms}", end=" ")
8 | else:
9 | if floors % 2 != 0:
10 | print(f"A{floors}{rooms}", end=" ")
11 | else:
12 | print(f"O{floors}{rooms}", end=" ")
13 | print("")
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Repository information
2 | These are my solutions through the course Python Basics from SoftUni
3 |
4 | ## Acquired skills
5 | - Working with the console (data input and output)
6 | - Working with loops (for)
7 | - Work with more complex logical checks
8 | - Working with logical checks (if-else)
9 | - Perform simple calculations
10 | - Working with more complex loops (nested for loops and while)
11 |
--------------------------------------------------------------------------------
/While Loop - Exercise/01. Old Books.py:
--------------------------------------------------------------------------------
1 | book_to_check = input()
2 |
3 | book_added_to_liberry = list()
4 | book_check_count = 0
5 |
6 | while True:
7 | book_added_to_liberry.append(input())
8 | if "No More Books" in book_added_to_liberry:
9 | print(f"The book you search is not here!\nYou checked {book_check_count} books.")
10 | break
11 | if book_to_check in book_added_to_liberry:
12 | print(f"You checked {book_check_count} books and found it.")
13 | break
14 | book_check_count += 1
15 |
--------------------------------------------------------------------------------
/While Loop - Exercise/01. Old Books_Problems_Descriptions.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/While Loop - Exercise/01. Old Books_Problems_Descriptions.docx
--------------------------------------------------------------------------------
/While Loop - Exercise/02. Exam Preparation.py:
--------------------------------------------------------------------------------
1 | allow_bad_grades = int(input())
2 |
3 | taks_names = list()
4 | scores = 0
5 | penalties = 0
6 | total_taks = 0
7 | task_score = 0
8 |
9 | while True:
10 | taks_names.append(input())
11 | if "Enough" in taks_names:
12 | average_score = (scores / total_taks)
13 | print(f"Average score: {average_score:.2f}\nNumber of problems: {total_taks}\nLast problem: {taks_names[-2]}")
14 | break
15 | task_score = int(input())
16 | if task_score <= 4:
17 | penalties += 1
18 | total_taks += 1
19 | scores += task_score
20 | else:
21 | scores += task_score
22 | total_taks += 1
23 | if penalties == allow_bad_grades:
24 | print(f"You need a break, {penalties} poor grades.")
25 | break
26 |
--------------------------------------------------------------------------------
/While Loop - Exercise/03. Vacation.py:
--------------------------------------------------------------------------------
1 | holiday_price = float(input())
2 | available_money = float(input())
3 |
4 | days_count = 0
5 | total_money = available_money
6 | last_type_of_action = list()
7 | count = 0
8 | while True:
9 | money_type = input()
10 | money = float(input())
11 | last_type_of_action.append(money_type)
12 | days_count += 1
13 | if money_type == "save":
14 | total_money += + money
15 | elif money_type == "spend":
16 | total_money += - money
17 | if total_money < 0:
18 | total_money = 0
19 | count = last_type_of_action.count("spend")
20 | if count > 5 and last_type_of_action[-1] == "spend" and last_type_of_action[-2] == "spend" and \
21 | last_type_of_action[-3] == "spend" and last_type_of_action[-4] == "spend" \
22 | and money_type == "spend":
23 | days_count += 1
24 | print(f"You can't save the money.\n{days_count}")
25 | break
26 | if total_money >= holiday_price:
27 | print(f"You saved the money for {days_count} days.")
28 | break
29 |
--------------------------------------------------------------------------------
/While Loop - Exercise/04. Walking.py:
--------------------------------------------------------------------------------
1 | total_steps = 0
2 | goal = 10000
3 | while True:
4 | steps_walk = input()
5 | if steps_walk == "Going home":
6 | steps_walk_in_a_day = int(input())
7 | total_steps += steps_walk_in_a_day
8 | if total_steps >= goal:
9 | total_steps += - goal
10 | print(f"Goal reached! Good job!\n{total_steps} steps over the goal!")
11 | break
12 | else:
13 | total_steps = goal - total_steps
14 | print(f"{total_steps} more steps to reach goal.")
15 | break
16 | total_steps += int(steps_walk)
17 |
18 | if total_steps >= goal:
19 | total_steps += - goal
20 | print(f"Goal reached! Good job!\n{total_steps} steps over the goal!")
21 | break
22 |
--------------------------------------------------------------------------------
/While Loop - Exercise/05. Coins.py:
--------------------------------------------------------------------------------
1 | change = float(input())
2 | coins = 0
3 | change = change * 100
4 |
5 | for x in (200, 100, 50, 20, 10, 5, 2):
6 | currCoins = int(change / x)
7 | change -= currCoins * x
8 | coins += currCoins
9 |
10 | currCoins = int(change)
11 | coins += currCoins
12 |
13 | print(coins)
14 |
15 |
16 |
17 | #
18 | # change = float(input())
19 | # coins = 0
20 | # change = change * 100
21 | #
22 | # currCoins = int(change / 200)
23 | # change -= currCoins * 200
24 | # coins += currCoins
25 | #
26 | # currCoins = int(change / 100)
27 | # change -= currCoins * 100
28 | # coins += currCoins
29 | #
30 | # currCoins = int(change / 50)
31 | # change -= currCoins * 50
32 | # coins += currCoins
33 | #
34 | # currCoins = int(change / 20)
35 | # change -= currCoins * 20
36 | # coins += currCoins
37 | #
38 | # currCoins = int(change / 10)
39 | # change -= currCoins * 10
40 | # coins += currCoins
41 | #
42 | # currCoins = int(change / 5)
43 | # change -= currCoins * 5
44 | # coins += currCoins
45 | #
46 | # currCoins = int(change / 2)
47 | # change -= currCoins * 2
48 | # coins += currCoins
49 | #
50 | # currCoins = int(change)
51 | # coins += currCoins
52 | #
53 | # print(coins)
--------------------------------------------------------------------------------
/While Loop - Exercise/06. Cake.py:
--------------------------------------------------------------------------------
1 | cake_width = int(input())
2 | cake_length = int(input())
3 |
4 | cake_size = cake_width * cake_length
5 | cake_slices_taken = 0
6 |
7 | while True:
8 | cake_slices = input()
9 |
10 | if cake_slices == "STOP":
11 | cake_size += - cake_slices_taken
12 | print(f"{cake_size} pieces are left.")
13 | break
14 |
15 | cake_slices_taken += + int(cake_slices)
16 | if cake_size < cake_slices_taken:
17 | cake_slices_taken += - cake_size
18 | print(f"No more cake left! You need {cake_slices_taken} pieces more.")
19 | break
20 |
--------------------------------------------------------------------------------
/While Loop - Exercise/07. Moving.py:
--------------------------------------------------------------------------------
1 | width = int(input())
2 | length = int(input())
3 | height = int(input())
4 |
5 | total_space = width * length * height
6 | space_left = 0
7 | while True:
8 | boxes_added = input()
9 | if boxes_added == "Done":
10 | space_left += - total_space
11 | print(f"{abs(space_left)} Cubic meters left.")
12 | break
13 | space_left += + int(boxes_added)
14 | if total_space < space_left:
15 | total_space = space_left - total_space
16 | print(f"No more free space! You need {abs(total_space)} Cubic meters more.")
17 | break
18 |
--------------------------------------------------------------------------------
/While Loop - Lab/01. Read Text.py:
--------------------------------------------------------------------------------
1 | while True:
2 | text = input()
3 | if text == "Stop":
4 | break
5 | else:
6 | print(text)
7 |
--------------------------------------------------------------------------------
/While Loop - Lab/01. Read Text_Problems_Description.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/venci0003/Python-Basics/a28ef4ef05ac658e6fbb6f0b2a57f83ee725842a/While Loop - Lab/01. Read Text_Problems_Description.docx
--------------------------------------------------------------------------------
/While Loop - Lab/02. Password.py:
--------------------------------------------------------------------------------
1 | name = input()
2 | password = input()
3 | check_password = input()
4 | while check_password != password:
5 | check_password = input()
6 | print(f"Welcome {name}!")
7 |
8 |
--------------------------------------------------------------------------------
/While Loop - Lab/03. Sum Numbers.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 | total = 0
3 | while True:
4 | a = int(input())
5 | total += a
6 | if total >= number:
7 | break
8 |
9 | print(total)
10 |
--------------------------------------------------------------------------------
/While Loop - Lab/04. Sequence 2k+1.py:
--------------------------------------------------------------------------------
1 | number = int(input())
2 |
3 | counter = 1
4 |
5 | while number >= counter:
6 | print(counter)
7 | counter = 2 * counter + 1
8 |
--------------------------------------------------------------------------------
/While Loop - Lab/05. Account Balance.py:
--------------------------------------------------------------------------------
1 | total = 0
2 | while True:
3 | money_deposit = input()
4 | if money_deposit[0] == "-":
5 | print("Invalid operation!")
6 | break
7 | elif money_deposit == "NoMoreMoney":
8 | break
9 | else:
10 | total += float(money_deposit)
11 | print("Increase:","{:.2f}".format(float(money_deposit)))
12 | print(f"Total: {total:.2f}")
13 |
--------------------------------------------------------------------------------
/While Loop - Lab/06. Max Number.py:
--------------------------------------------------------------------------------
1 | number = input()
2 | max_number = int(number)
3 |
4 | while number != "Stop":
5 | num = int(number)
6 |
7 | if num > max_number:
8 | max_number = num
9 | number = input()
10 |
11 | print(max_number)
12 |
13 |
14 |
15 | #
16 | #
17 | # total = list()
18 | # while True:
19 | # numbers = input()
20 | # if numbers != "Stop":
21 | # total.append(int(numbers))
22 | # else:
23 | # total.sort()
24 | # print(total[-1])
25 | # break
26 |
--------------------------------------------------------------------------------
/While Loop - Lab/07. Min Number.py:
--------------------------------------------------------------------------------
1 | number = input()
2 | min_number = int(number)
3 |
4 | while number != "Stop":
5 | num = int(number)
6 |
7 | if num < min_number:
8 | min_number = num
9 | number = input()
10 |
11 | print(min_number)
12 |
13 |
14 |
15 | #
16 | # total = list()
17 | # while True:
18 | # numbers = input()
19 | # if numbers != "Stop":
20 | # total.append(int(numbers))
21 | # else:
22 | # total.sort()
23 | # print(total[0])
24 | # break
25 |
--------------------------------------------------------------------------------
/While Loop - Lab/08. Graduation.py:
--------------------------------------------------------------------------------
1 | student_name = input()
2 | total = list()
3 | classes = 0
4 | scored_under_four = 0
5 | while True:
6 | grade = float(input())
7 | if grade >= 4.00:
8 | classes += 1
9 | total.append(grade)
10 | else:
11 | scored_under_four += 1
12 | if scored_under_four == 2:
13 | classes += 1
14 | print(f"{student_name} has been excluded at {classes} grade")
15 | break
16 | elif classes == 13:
17 | total = sum(total) / 12
18 | print(f"{student_name} graduated. Average grade: {total:.2f}")
19 | break
20 | elif classes == 12:
21 | total = sum(total) / 12
22 | print(f"{student_name} graduated. Average grade: {total:.2f}")
23 | break
24 |
--------------------------------------------------------------------------------