348 lines
12 KiB
Python
348 lines
12 KiB
Python
''' ****** Задание 1 ********
|
||
*** Вывод текста ***
|
||
'''
|
||
#print("Привет, Яндекс!")
|
||
|
||
''' ****** Задание 2 ********
|
||
*** Диалоговая программа, которая сначала спросит имя пользователя, а затем поприветствует его. ***
|
||
'''
|
||
#print("Как Вас зовут?")
|
||
#user_name = input()
|
||
#print("Привет, " + user_name)
|
||
|
||
''' ****** Задание 3 ********
|
||
*** Принимает одну строку и выводит её трижды ***
|
||
'''
|
||
#info = input()
|
||
#print(info)
|
||
#print(info)
|
||
#print(info)
|
||
|
||
''' ****** Задание 4 ********
|
||
*** Вычислите стоимость покупки, а затем найдите разность ***
|
||
'''
|
||
#has = int(input())
|
||
#need = 38 * 5 // 2
|
||
#answer = has - need
|
||
#print(answer)
|
||
|
||
''' ****** Задание 5 ********
|
||
*** Вычислить сдачу ***
|
||
'''
|
||
#price = int(input())
|
||
#weight = int(input())
|
||
#money = int(input())
|
||
#cost = price * weight
|
||
#change = money - cost
|
||
#print(change)
|
||
|
||
''' ****** Задание 6 ********
|
||
*** Рассчитывает стоимость покупки и печатает чек в заданном формате ***
|
||
'''
|
||
# Четыре строки ввода:
|
||
# 1. Название товара (строка)
|
||
# item_name = input()
|
||
#
|
||
# # 2. Цена товара за килограмм (натуральное число)
|
||
# price_per_kg = int(input())
|
||
#
|
||
# # 3. Вес товара (натуральное число)
|
||
# weight_kg = int(input())
|
||
#
|
||
# # 4. Количество денег у пользователя (натуральное число)
|
||
# money_given = int(input())
|
||
|
||
# Расчеты:
|
||
# Итоговая стоимость
|
||
# total_cost = price_per_kg * weight_kg
|
||
#
|
||
# # Сдача
|
||
# change = money_given - total_cost
|
||
#
|
||
# #Формат вывода:
|
||
# print("Чек")
|
||
# print(f"{item_name} - {weight_kg}кг - {price_per_kg}руб/кг")
|
||
# print(f"Итого: {total_cost}руб")
|
||
# print(f"Внесено: {money_given}руб")
|
||
# print(f"Сдача: {change}руб")
|
||
|
||
''' ****** Задание 7 ********
|
||
*** Которая N раз выводит строку «Купи слона!». ***
|
||
'''
|
||
# n = int(input())
|
||
# for _ in range(n):
|
||
# print("Купи слона!")
|
||
|
||
''' ****** Задание 8 ********
|
||
*** Выводит N строк наказания. ***
|
||
'''
|
||
# n = int(input())
|
||
# punishment = input()
|
||
# print(f'Я больше никогда не буду писать "{punishment}"!\n' * n, end='')
|
||
|
||
''' ****** Задание 9 ********
|
||
*** Сколько кусков колбасы съедят N детей за M минут.***
|
||
'''
|
||
# n = int(input())
|
||
# m = int(input())
|
||
#
|
||
# total_sausages = (n * m) / 2
|
||
#
|
||
# print(int(total_sausages))
|
||
|
||
''' ****** Задание 10 ********
|
||
*** Формирование карточки для личного дела ребёнка.***
|
||
'''
|
||
# name = input()
|
||
# locker_number = input()
|
||
#
|
||
# # Extract digits from the locker number
|
||
# group_number = locker_number[0]
|
||
# bed_number = locker_number[1]
|
||
# child_order_in_group = locker_number[2]
|
||
#
|
||
# # Format and print the output
|
||
# print(f"Группа №{group_number}.")
|
||
# print(f"{child_order_in_group}. {name}.")
|
||
# print(f"Шкафчик: {locker_number}.")
|
||
# print(f"Кроватка: {bed_number}.")
|
||
|
||
''' ****** Задание 11 ********
|
||
*** Числа вида abcd составляет число badc***
|
||
'''
|
||
# number = input()
|
||
#
|
||
# # Extract digits
|
||
# a = number[0]
|
||
# b = number[1]
|
||
# c = number[2]
|
||
# d = number[3]
|
||
#
|
||
# # Form the new number by rearranging digits
|
||
# new_number = b + a + d + c
|
||
#
|
||
# print(new_number)
|
||
|
||
''' ****** Задание 12 ********
|
||
*** Складывает два числа поразрядно без учёта переносов. ***
|
||
'''
|
||
# # Read the two natural numbers as input
|
||
# num1 = int(input())
|
||
# num2 = int(input())
|
||
#
|
||
# # Initialize the result and a multiplier for placing digits in the correct position
|
||
# result = 0
|
||
# power_of_10 = 1
|
||
#
|
||
# # Loop as long as there are digits left in either number
|
||
# while num1 > 0 or num2 > 0:
|
||
# # Get the last digit of num1
|
||
# digit1 = num1 % 10
|
||
# # Get the last digit of num2
|
||
# digit2 = num2 % 10
|
||
#
|
||
# # Sum the current pair of digits
|
||
# sum_of_current_digits = digit1 + digit2
|
||
#
|
||
# # Get the units digit of the sum (ignoring any carry-over)
|
||
# result_digit = sum_of_current_digits % 10
|
||
#
|
||
# # Add this result digit to our overall result,
|
||
# # multiplied by the appropriate power of 10 to place it correctly
|
||
# result += result_digit * power_of_10
|
||
#
|
||
# # Remove the last digit from num1
|
||
# num1 //= 10
|
||
# # Remove the last digit from num2
|
||
# num2 //= 10
|
||
#
|
||
# # Move to the next power of 10 for the next digit position
|
||
# power_of_10 *= 10
|
||
#
|
||
# # Print the final result
|
||
# print(result)
|
||
|
||
''' ****** Задание 13 ********
|
||
*** Раздать конфеты детям на новогоднем утреннике. ***
|
||
'''
|
||
# # Read the number of children
|
||
# n = int(input())
|
||
# # Read the number of candies
|
||
# m = int(input())
|
||
#
|
||
# # Calculate the number of candies each child receives (integer division)
|
||
# candies_per_child = m // n
|
||
#
|
||
# # Calculate the remaining candies (remainder of the division)
|
||
# remaining_candies = m % n
|
||
#
|
||
# # Print the results, each on a new line
|
||
# print(candies_per_child)
|
||
# print(remaining_candies)
|
||
|
||
''' ****** Задание 14 ********
|
||
*** Определяет максимальное количество ходов, которое потребуется, чтобы найти зелёный шарик. ***
|
||
'''
|
||
# # Read the number of red balls
|
||
# red_balls = int(input())
|
||
#
|
||
# # Read the number of green balls
|
||
# green_balls = int(input())
|
||
#
|
||
# # Read the number of blue balls
|
||
# blue_balls = int(input())
|
||
#
|
||
# # Calculate the maximum number of moves
|
||
# # In the worst-case scenario, all red and blue balls are drawn first,
|
||
# # and then the first green ball is drawn.
|
||
# maximum_moves = red_balls + blue_balls + 1
|
||
#
|
||
# # Print the result
|
||
# print(maximum_moves)
|
||
|
||
''' ****** Задание 15 ********
|
||
*** N часов M минут владелец магазина заказал доставку нового товара. Оператор сообщил, что продукты доставят через T минут.
|
||
Сколько будет времени на электронных часах, когда привезут долгожданные продукты? ***
|
||
'''
|
||
# # Read the initial hour, minute, and delivery time in minutes
|
||
# hour = int(input())
|
||
# minute = int(input())
|
||
# delivery_time = int(input())
|
||
#
|
||
# # Calculate the total minutes from midnight for the initial time
|
||
# total_minutes_initial = hour * 60 + minute
|
||
#
|
||
# # Add the delivery time to get the total minutes from midnight for the delivery
|
||
# total_minutes_delivery = total_minutes_initial + delivery_time
|
||
#
|
||
# # Calculate the new hour and minute
|
||
# # The modulo 1440 (24 hours * 60 minutes) handles wrapping around midnight
|
||
# delivery_hour = (total_minutes_delivery // 60) % 24
|
||
# delivery_minute = total_minutes_delivery % 60
|
||
#
|
||
# # Format the output to ensure two digits for hours and minutes
|
||
# # This uses f-strings with format specifiers:
|
||
# # :02d means "format as a decimal integer, padding with a leading zero if it's less than 2 digits"
|
||
# print(f"{delivery_hour:02d}:{delivery_minute:02d}")
|
||
|
||
''' ****** Задание 16 ********
|
||
*** Склад находится на отметке A км, а магазин — B км. Средняя скорость автомобиля, доставляющего товары, C км/ч.
|
||
За какое время продукты попадают со склада в магазин? ***
|
||
'''
|
||
# # Read the coordinates of the warehouse (A) and the store (B)
|
||
# a = int(input())
|
||
# b = int(input())
|
||
#
|
||
# # Read the average speed of the delivery car (C)
|
||
# c = int(input())
|
||
#
|
||
# # Calculate the distance between the warehouse and the store
|
||
# # We use abs() to ensure the distance is always positive, regardless of A and B order.
|
||
# distance = abs(b - a)
|
||
#
|
||
# # Calculate the time taken (Time = Distance / Speed)
|
||
# # Since C is an integer, dividing distance by C will result in a float automatically.
|
||
# time_in_hours = distance / c
|
||
#
|
||
# # Print the result formatted to two decimal places
|
||
# # The f-string with ":.2f" format specifier achieves this.
|
||
# print(f"{time_in_hours:.2f}")
|
||
|
||
''' ****** Задание 17 ********
|
||
*** Поможет магазину посчитать общую сумму выручки, учитывая, что кассовый аппарат выдаёт сумму последней покупки в двоичной системе счисления. ***
|
||
'''
|
||
# # Read the current total revenue (in decimal)
|
||
# current_revenue_decimal = int(input())
|
||
#
|
||
# # Read the last purchase amount (in binary string)
|
||
# last_purchase_binary = input()
|
||
#
|
||
# # Convert the binary string to a decimal integer
|
||
# last_purchase_decimal = int(last_purchase_binary, 2)
|
||
#
|
||
# # Calculate the total revenue by adding the decimal values
|
||
# total_revenue = current_revenue_decimal + last_purchase_decimal
|
||
#
|
||
# # Print the total revenue
|
||
# print(total_revenue)
|
||
|
||
''' ****** Задание 18 ********
|
||
*** Из двоичной в десятичную систему ***
|
||
'''
|
||
# # Read the purchase price in binary (as a string)
|
||
# purchase_price_binary = input()
|
||
#
|
||
# # Read the denomination of the user's bill (in decimal)
|
||
# bill_denomination_decimal = int(input())
|
||
#
|
||
# # Convert the binary purchase price to a decimal integer
|
||
# purchase_price_decimal = int(purchase_price_binary, 2)
|
||
#
|
||
# # Calculate the change
|
||
# change_decimal = bill_denomination_decimal - purchase_price_decimal
|
||
#
|
||
# # Print the change
|
||
# print(change_decimal)
|
||
|
||
''' ****** Задание 19 ********
|
||
*** Выводит красиво оформленный чек. ***
|
||
'''
|
||
# # Read input data
|
||
# product_name = input()
|
||
# price_per_kg = int(input())
|
||
# weight_kg = int(input())
|
||
# money_paid = int(input())
|
||
#
|
||
# # Calculate total cost and change
|
||
# total_cost = price_per_kg * weight_kg
|
||
# change = money_paid - total_cost
|
||
#
|
||
# # Define the total width for each line
|
||
# total_width = 35
|
||
#
|
||
# # Print the top border
|
||
# print("=" * 16 + "Чек" + "=" * 16)
|
||
#
|
||
# # Print product line
|
||
# # "Товар: " has 7 characters. Remaining width for product_name is 35 - 7 = 28.
|
||
# print(f"Товар: {product_name.rjust(total_width - 7)}")
|
||
#
|
||
# # Print price details line
|
||
# # "Цена: " has 10 characters. Remaining width for price_details_str is 35 - 10 = 25.
|
||
# price_details_str = f"{weight_kg}кг * {price_per_kg}руб/кг"
|
||
# print(f"Цена: {price_details_str.rjust(total_width - 10)}")
|
||
#
|
||
# # Print total cost line
|
||
# # "Итого: " has 7 characters. Remaining width for total_cost_str is 35 - 7 = 28.
|
||
# total_cost_str = f"{total_cost}руб"
|
||
# print(f"Итого: {total_cost_str.rjust(total_width - 7)}")
|
||
#
|
||
# # Print money paid line
|
||
# # "Внесено: " has 9 characters. Remaining width for money_paid_str is 35 - 9 = 26.
|
||
# money_paid_str = f"{money_paid}руб"
|
||
# print(f"Внесено: {money_paid_str.rjust(total_width - 9)}")
|
||
#
|
||
# # Print change line
|
||
# # "Сдача: " has 7 characters. Remaining width for change_str is 35 - 7 = 28.
|
||
# change_str = f"{change}руб"
|
||
# print(f"Сдача: {change_str.rjust(total_width - 7)}")
|
||
#
|
||
# # Print the bottom border
|
||
# print("=" * total_width)
|
||
|
||
''' ****** Задание 20 ********
|
||
*** Вес каждой партии котлет. ***
|
||
'''
|
||
# N = int(input())
|
||
# M = int(input())
|
||
# K1 = int(input())
|
||
# K2 = int(input())
|
||
#
|
||
# # Проверяем условие K2 < M < K1
|
||
# if K2 >= M or M >= K1:
|
||
# print("Нет решения в натуральных числах")
|
||
# else:
|
||
# x = N * (M - K2) // (K1 - K2)
|
||
# y = N * (K1 - M) // (K1 - K2)
|
||
# print(x, y)
|