Write a function that takes a number and rounds it up to the nearest integer
Maximum Number of Books
There are multiple (T) bookstores in the area.Each shopkeeper has a list of B integers that represents the cost of each book.You have different pocket money(P) for each bookstore.Write a program to calculate the maximum number of books you can buy in each store with the corresponding pocket money.
Explanation
Given P = 600 and B = [120, 140, 110, 180, 120, 110] with a pocket money of 600, we can buy the books at index 0,1,2,4,5 , whose sum is 120+140+110+120+110 is equal to P.
Given P = 300 and B = [120 110 1300 130] with a pocket money of 300, we can buy the books at index 0,1 whose sum is 120 + 110 and is less than P.
Given P = 100 and B = [220 1000 500 2000] with pocket money of 100, we can't buy any book. So the output should be Retry.
Sample Input1
3
6 100
20 40 10 80 20 10
4 70
20 10 300 30
4 200
220 1000 500 2000
Sample Output1
5
3
Sample Input2
2
8 250
2070 1350 365 2750 30 20 140 240
4 500
1070 2893 2200 39
Sample Output2
3
1
Maximum Number of Books
There are multiple (T) bookstores in the area.Each shopkeeper has a list of B integers that represents the cost of each book.You have different pocket money(P) for each bookstore.Write a program to calculate the maximum number of books you can buy in each store with the corresponding pocket money.
Explanation
Given P = 600 and B = [120, 140, 110, 180, 120, 110] with a pocket money of 600, we can buy the books at index 0,1,2,4,5 , whose sum is 120+140+110+120+110 is equal to P.
Given P = 300 and B = [120 110 1300 130] with a pocket money of 300, we can buy the books at index 0,1 whose sum is 120 + 110 and is less than P.
Given P = 100 and B = [220 1000 500 2000] with pocket money of 100, we can't buy any book. So the output should be Retry.
Sample Input1
3
6 100
20 40 10 80 20 10
4 70
20 10 300 30
4 200
220 1000 500 2000
Sample Output1
5
3
Sample Input2
2
8 250
2070 1350 365 2750 30 20 140 240
4 500
1070 2893 2200 39
Sample Output2
3
1
Repeated Numbers
Eren wants to decode a number.After lots of trial and error, he finally figured out that the number is a count of repeated single-digit integers.
Write a program to help Eren print the decoded number given a string of integers N.
Input
The first line contains a string of integers N.
Output
The output contains a single integer representing count of repeated numbers in the input.
Explanation
For N = 212311 ,
1 and 2 are repeated.Therefore, the output is 2.
Sample Input1
212311
Sample Output1
2
Sample Input2
111
Sample Output2
1
Repeated Numbers
Eren wants to decode a number.After lots of trial and error, he finally figured out that the number is a count of repeated single-digit integers.
Write a program to help Eren print the decoded number given a string of integers N.
Input
The first line contains a string of integers N.
Output
The output contains a single integer representing count of repeated numbers in the input.
Explanation
For N = 212311 ,
1 and 2 are repeated.Therefore, the output is 2.
Sample Input1
212311
Sample Output1
2
Sample Input2
111
Sample Output2
1
Write a function daysInMonth(month, year)
The function receives two integers: month as a first parameter and year as a second parameter.
If month is a February, the function checks if the current year is a leap year to determine how many days February contains.
For the remaining months year check up is not required.
In order to find out whether the year is leap, use function that you defined for the Problem 1 solution.
If year is not provided, the default value 2022 should be assigned to the year automatically.
You must use looping to solve the problem
Given the following variables:
slash = "/"
backslash = "\\"
asterisk = "*"
uscore = "_"
Define a function that builds the following patterns based on variables given above:
pattern1:
/\/\/\/\/\/\/\/\/\
pattern2:
*-*-*-*-*-*-*-*-*
Tip: You may pass those symbols to the function as arguments. For example, your function header could look as following:
def create_pattern(symbol1,symbol2):
where:
symbol1 will be assigned to slash
symbol2 will be assigned to backshash
The same for the second pattern:
symbol1 will be assigned to asterisk
symbol2 will be assigned to underscore
Once the function is ready, you can use it to print the following pattern on the screen:
create_pattern(slash,backslash)
create_pattern(asterisk,uscore)
create_pattern(asterisk,uscore)
create_pattern(asterisk,uscore)
create_pattern(slash,backslash)
You were asked to check if a box with given sides could fit into a package.
Your function should have the following interface:
def boxToPackageSizeMatchCheck(box, package):
Where box and package are lists of 3 elements of integer numbers. Each element in the list represents width, height and dept.
To make the task easier for you, we are going to compare only related pairs of width, height and dept (we cannot spin or rotate box or package).
1. What are optional function arguments & default values? Give an example.
2.Why should the required arguments appear before the optional arguments in a function definition?