A
A
Arthur2020-05-21 13:14:38
Python
Arthur, 2020-05-21 13:14:38

How to write an alternative program so that the following items are used at least 1 time?

Three ways out: write an alternate version of Exercise 7.4 or Exercise 7.5 in which each item in the following list occurs at least once: • Ending the conditional loop in the while statement. • Controlling the duration of the loop depending on the active variable. • Exiting the loop with a break command if the user enters the value 'quit'

Attached tasks 7.4 and 7.5
Task 7.4

toppings = "\nВведите дополнение для пиццы"
toppings += "\nнажмите 'quit' для выхода "
message = ""
while message != 'quit':
    message = input(toppings)
    if message != 'quit':
        print(f"{message} включено в заказ")
# Задание 7.5
years = "Введите свой возраст"
message = ""
while message != 'quit':
    message = int(input(years))
    if message < 3:
        print("Для вас билет бесплатный")
    elif message <= 12:
        print("Для  тебя это стоит 10$")
    elif message > 12:
        print("Твоя стоимость 15$")

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
a, 2020-05-21
@MZOK

If I understand you correctly, then

toppings = "\nВведите дополнение для пиццы"
toppings += "\nнажмите 'quit' для выхода "
message = ""
finish = False
while message != 'quit' and not finish:
    message = input(toppings)
    if message != 'quit':
        print(f"{message} включено в заказ")
    finish = True
# Задание 7.5
finish = False
years = "Введите свой возраст"
message = ""
while message != 'quit' and not finish:
    message = int(input(years))
    if message < 3:
        print("Для вас билет бесплатный")
    elif message <= 12:
        print("Для  тебя это стоит 10$")
    elif message > 12:
        print("Твоя стоимость 15$")
    finish = True

C
CyBeHuP, 2020-07-29
@CyBeHuP

For a long time he was stupid on the task, but he did it

mess = ("\nВведите возраст: ")

times = 0

active = True

while active:
  
  age = input(mess)
  
  times += 1
  if times == 10:
      active = False
      print("Попытки закончились")
  print("Попыток " + str(times))

  if age.lower() == 'выход':
      break

  elif int(age) < 3:
    print("\nВаш возраст - " + age + "\nСтоимость билета - 0")
  elif int(age) <= 12:
    print("\nВаш возраст - " + age + "\nСтоимость билета - 10")
  elif int(age) > 12:
    print("\nВаш возраст - " + age + "\nСтоимость билета - 15")

A
Artur, 2020-05-21
@fr0styy

Solved the problem for 7.4

toppings = "\nВведите дополнение для пиццы"
toppings += "\nнажмите 'quit' для выхода "
message = ""
active = True
while active:
    message = input(toppings)
    if message == 'quit':
        break
    if message != 'quit':
        print(f"{message} включено в заказ")

Remaining 7.5)

J
JOKERYGA, 2021-11-25
@JOKERYGA

age = "How old are you?"
age += "\nEnter 'quit' to exit: "
messange = ""
active = True
while active:
messange = input(age)
if messange == 'quit':
active = False
break
if messange != 'quit':
age1 = int(messange)
if age1 <= 3:
print("Cinema is free")
elif age1 <= 12:
print("Cinema cost's $10")
else:
print("Cinema cost's $15")
----- -------------
To solve the problem, I had to lie down and rest for about 15 minutes. It often helps if dullness begins

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question