Assume, you have been given a dictionary named dict_1. The values of the dictionary will be a list or a tuple depending on the case of the dictionary key. If the key is in lower case, then the value will be in list format. If the key is in upper case, then the value will be in tuple format. Now, write a Python program that creates a new dictionary named “dict_primes” that contains only the prime numbers in the value. Then, finally, print the dictionary dict_primes. ============================================================================= Given dictionary1: {"a":[5,2,55,17],"P":(11,121,222),"B":(37,53,71),"c":[45,92,50]} Sample Output 1: dict_primes = {'a': [5, 2, 17], 'P': (11,), 'B': (37, 53, 71), 'c': []}
Write a Python program that takes a tuple of tuples as an input from the user. Then calculates the average value of the numbers for each tuple of tuples and find the tuple whose sum is the maximum. [You are not allowed to use max () function here. You are not allowed to use Regex split in this task.] Hints: Since the input function converts everything to string by default. You might need to use strip() and split() to get the data/tuples. =========================================================== Sample Input1: ((33, 22, 11), (30, 45, 56, 45,20), (81, 90, 39, 45), (1, 2, 3, 4,5,6)) Sample Output2: Average of tuples: [22.0, 39.2, 63.75, 3.5] Tuple with maximum sum is (81, 90, 39, 45)
2.We all know that the additive primaries are red, green, and blue. Now, write a Python program that will take a color sequence as a
string from the user where R represents Red, G represents Green and B represents Blue. The program should print the choice of
colors that is actually a tuple containing the sub-tuples as (color_name, color_frequency) only if the color_frequency for that color is
at least one in the given color sequence. [You are not allowed to use count() function here.]
===========================================================
Sample Input1:
"RGBRRGBBR"
Sample Output1:
(('Red', 4), ('Green', 2), ('Blue', 3))
Explanation2:
In the given color sequence, “R”, “B”, and “G” have color_frequency at least one (minimum1). So, “Red”, “Green” and “Blue” are
present in the output.
Magic number: If the summation of even indexed digits is equal to the summation of odd indexed digits, then the number is
a magic number.
Now, write a Python program that will take a string of numbers where each number is separated by a comma. The program should
print a tuple containing two sub-tuples, where the first sub-tuple will hold the magic numbers and the second sub-tuple will hold
the non-magic numbers.
Sample Input1:
"1232, 4455, 1234, 9876, 1111"
Sample Output1:
((1232, 4455, 1111), (1234, 9876))
Use Monte Carlo integration to estimate the integral of a function. Also calculate the error-> limit(1,0) ∫ 𝑥 ^2 (3𝑥 + 1)𝑑x
Write a program that prompts the user to enter an integer and determines
whether it is divisible by 5 and 6, whether it is divisible by 5 or 6, and whether
it is divisible by 5 or 6, but not both
Find latitude and longitude of first 20 countries with a population greater than or equal to the population limit given below. Use the country details from this dataset(https://cdn.jsdelivr.net/gh/apilayer/restcountries@3dc0fb110cd97bce9ddf27b3e8e1f7fbe115dc3c/src/main/resources/countriesV2.json).
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Assume radius of earth: 6371 km
Round length of each line and final result to 2 decimal points
If co-ordinates are missing for any country use 0.000 N 0.000 E
Population limit :300
input ten values and get the average temperature for that day. if the average temperature value is in between 970Fahrenheit and 990 Fahrenheit then display the message “Your body temperature is normal…”. If it is more than 104.0 Fahrenheit then display the message “You have a fever caused by an infection or illness…
myList = list(range(0,10))
for x in myList:
print(myList[x]/myList[x-1])
Please fix the error
Write a Python function called sumList () which will receive a list of integers as input parameter. sumList() must: a) Print the list b) Sum all the numbers in a list and print the total. The main section of your program must: c) Ask the user how many numbers the list should contain; d) Create the list accordingly (containing randomly generated integers between 0 and 100); e) Pass the list to sumList () for processin