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
I need flowchart for weight of a motorbike in python
Write a function named add_value that has a single parameter. This parameter will be a list/array. Your function needs to add the value 21 to the parameter after its last entry. Because lists and arrays are mutable, your function does not have to return a value.
Math Quiz
Riya took part in a maths quiz competition. To win the prize money she has to solve a tricky question at the end.For a given list of integers, write a program where all the integers in a given index range to be added.
She will be given M multiple ranges, where she should print the sum of numbers for each corresponding range.
Note: The limits in the range are both inclusive.
Input
The first line f input is space-separated integers.
The second line of input is a positive integer M denoting the number of index ranges.
The next M lines contain two space-separated integers of the range.
Output
The output should be M lines.
Each line contains an integer that represents the sum for the corresponding ranges.
Sample Input1
1 3 4 5 6
5
3 5
Sample Output1
12
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