Skip to content

Instantly share code, notes, and snippets.

# We would like to connect chocolate cubes to a row x cm long. We have -
# - small chocolate cubes 1 cm long and 5 cm large chocolate cubes.
# The function receives the number of small cubes (small), the number of large cubes (big), -
# - and the desired line length (x). The function returns true -
# - if it is possible to create an x-length row using the number of all or part of the chocolate cubes received.
>>> chocolate_maker(3, 1, 8)
"""
Legend of "The Three Little Pigs" tells of three pigs that lived under the threat of a werewolf. With a view to providing shelter for themselves, they began to gather building materials together.
Write a plan that shows the total number of pigs collected by the pigs, and the number of bricks available to each pig, according to the instructions below.
Guidelines
The program will receive as a three-digit input (assume the input is correct). Each number in this number represents the number of bricks collected by another pig.
The program will print the following output:
1. The total number of bricks (the amount) collected by the piglets (ie the sum of the three digits)
2. The number of bricks that each pig will receive if they divide the total number of bricks equally among everyone
"""
Write a program that gets the user a date in dd / mm / yyyy format and prints the day of the week for the entered date.
dd/mm/yyyy
calendar , weekday
"""
"""
The function accepts three values representing ages: a, b, c and returns their sum.
Instructions
1. If the function is called without parameters, the default value of each age is 13.
2. If one of the values represents an age of adolescents between 13 and 19 (including them) but with the exception of ages 15 and 16 - fix its value using the function described below, so it is calculated as 0.
3. Write auxiliary function fix_age
"""
Write a function called distance
The function receives three integers: num1, num2, num3.
The function returns True if both conditions are met:
1. One of the numbers num2 or num3 is "close" to num1. "Close" = absolute distance 1.
"""
Write a function called last_early
The function accepts as a string parameter. The function returns True if the last character that appears in the string also appears earlier. Otherwise the function returns False.
Instructions
"""
Write a program that receives a string from the user and prints 'OK' if it is Plindrome, otherwise 'NOT'.
Instructions
Plindrome is a string (word, number, or any sequence of characters) whose right-to-left reading is the same as reading from left to right. pay attention:
No small or large letters are important.
string = input("Please enter a string:")
# spaceships
middle = len(string)//2
first_half = string [0:middle]
second_half = string [middle:]
str = input("Please enter a string:")
# ddar astronaut. pldase, stop drasing md!
a = str[1:-1]
all_but_first = a.replace("d","e")
print(all_but_first)
choice = int(input())
10
if choice == 1:
print("You've chosen one")