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?
Write functions to solve the following problems:
Write a fuction isLeapYear with a parameter of type int named year.
The parameter needs to be greater than or equal to 1 and less than or equal to 9999.
If the parameter is not in that range return False.
Otherwise, if it is in the valid range, calculate if the year is a leap year and return True if it is a leap year, otherwise return False.
Tip: To determine whether a year is a leap year, follow these steps:
1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.
2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4.
3. If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5.
4. The year is a leap year (it has 366 days). The method isLeapYear needs to return True.
5. The year is not a leap year (it has 365 days). The method isLeapYear needs to return False
LABELLING NUMBERS
0 EVEN
1 ODD
2 EVEN
3 ODD
1.How do you store the result of a function in a variable?
2.. What are some popular Python libraries?
Friend and Enemy
A group of F friends went to a haunted house.Each member was given a shirt with a number on it ranging from 1 to F. As they entered the haunted house, one of them was kidnapped and an enemy joined them.But unfortunately, the enemy didn't wear the shirt with the same number as the kidnapped one, instead wore the same as some other person.Find the numbers on the shirts of the enemy and the kidnapped person.
Input
The input is a single line containing space-separated positive integers from 1 to F.
Output
The output should be a single line containing the shirt numbers of the enemy and kidnapped person separated by a space.
Explanation
The given array is 3 1 5 2 1.
In the range from 1 to 5, the number 1 has occured twice and 4 is the missing number. So, 1 belongs to the enemy's shirt, and 4 belongs to kidnapped.Hence, the output should be 1 4.
Sample Input1
3 1 5 2 1
Sample Output1
1 4
Sample Input2
1 2 2 4
Sample Output2
2 3