Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1
- searched_book = input()
- current_book = input()
- books_counter = 0
- book_is_found = False
- while current_book != "No More Books":
- if current_book == searched_book:
- book_is_found = True
- break
- books_counter += 1
- current_book = input()
- if book_is_found:
- print(f"You checked {books_counter} books and found it.")
- else:
- print("The book you search is not here!")
- print(f"You checked {books_counter} books.")
- #2
- maximum_bad_grades = int(input())
- current_task = input()
- bad_grades_counter = 0
- average_score = 0
- total_tasks_counter = 0
- last_task_name = ""
- got_too_many_bad_grades = False
- while current_task != "Enough":
- current_grade = int(input())
- if current_grade <= 4:
- bad_grades_counter += 1
- if bad_grades_counter == maximum_bad_grades:
- got_too_many_bad_grades = True
- break
- average_score += current_grade
- total_tasks_counter += 1
- last_task_name = current_task
- current_task = input()
- if got_too_many_bad_grades: # if got_too_many_bad_grades == True
- print(f"You need a break, {bad_grades_counter} poor grades.")
- else:
- average_score /= total_tasks_counter
- # average_score = average_score / total_tasks_counter
- print(f"Average score: {average_score:.2f}")
- print(f"Number of problems: {total_tasks_counter}")
- print(f"Last problem: {last_task_name}")
- #3
- needed_money = float(input())
- money_in_hand = float(input())
- total_days_counter = 0
- spend_counter = 0
- spending_too_many_days_in_a_row = False
- while money_in_hand < needed_money:
- action = input()
- current_sum = float(input())
- total_days_counter += 1
- if action == "spend":
- spend_counter += 1
- if spend_counter == 5:
- spending_too_many_days_in_a_row = True
- break
- money_in_hand -= current_sum
- if money_in_hand < 0:
- money_in_hand = 0
- elif action == "save": #else
- money_in_hand += current_sum
- spend_counter = 0
- if spending_too_many_days_in_a_row:
- print("You can't save the money.")
- print(total_days_counter)
- else:
- print(f"You saved the money for {total_days_counter} days.")
- #4
- target_steps = 10000
- total_steps = 0
- while total_steps < target_steps:
- command = input()
- if command == "Going home":
- last_steps = int(input())
- total_steps += last_steps
- break
- current_steps = int(command)
- total_steps += current_steps
- difference = abs(target_steps - total_steps)
- if total_steps >= target_steps:
- print("Goal reached! Good job!" )
- print(f"{difference} steps over the goal!")
- else:
- print(f"{difference} more steps to reach goal.")
- #5
- change = float(input())
- change = int(change * 100)
- coins_counter = 0
- while change > 0:
- if change >= 200:
- change -= 200
- elif change >= 100:
- change -= 100
- elif change >= 50:
- change -= 50
- elif change >= 20:
- change -= 20
- elif change >= 10:
- change -= 10
- elif change >= 5:
- change -= 5
- elif change >= 2:
- change -= 2
- elif change == 1:
- change -= 1
- coins_counter += 1
- print(coins_counter)
- # 5.1
- change = float(input())
- change = int(change * 100)
- coins_counter = 0
- coins_counter += change // 200
- change = change % 200
- coins_counter += change // 100
- change = change % 100
- coins_counter += change // 50
- change = change % 50
- coins_counter += change // 20
- change = change % 20
- coins_counter += change // 10
- change = change % 10
- coins_counter += change // 5
- change = change % 5
- coins_counter += change // 2
- change = change % 2
- if change == 1:
- coins_counter += 1
- print(coins_counter)
- #6
- width = int(input())
- length = int(input())
- total_pieces = width * length
- no_more_cake_left = False
- command = input()
- while command != "STOP":
- current_pieces = int(command)
- total_pieces -= current_pieces
- if total_pieces < 0:
- no_more_cake_left = True
- break
- command = input()
- if no_more_cake_left:
- print(f"No more cake left! You need {abs(total_pieces)} pieces more.")
- else:
- print(f"{total_pieces} pieces are left." )
- #7
- width = int(input())
- length = int(input())
- heigth = int(input())
- there_is_more_free_space = True
- total_volume = width * length * heigth
- command = input()
- while command != "Done":
- current_number_of_boxes = int(command)
- total_volume -= current_number_of_boxes
- if total_volume < 0:
- there_is_more_free_space = False
- break
- command = input()
- if there_is_more_free_space: # if there_is_more_free_space == True
- print(f"{total_volume} Cubic meters left.")
- else:
- print(f"No more free space! You need {abs(total_volume)} Cubic meters more.")
Advertisement
Add Comment
Please, Sign In to add comment