This repository is created for the solution of Fresco Play Practice questions for Python.
Now, lets have problem statements component wise in the following sections.
This program calculate the key entry time.
Story: Each day, employees from an e-commerce company have to type a string of number into a console using a 3 x 3 numeric keypad to enter their building. Every day the numbers on the keypad are mixed up.
Use the following rules to calculate total amount of time it takes to type a string:
- It takes 0 second to move their finger to the first key and it takes 0 second to press the key where the finger is located any number of times.
- They can move their finger to one location to any adjacent key in 1 second. Adjacent keys include those on a diagonal.
- Moving to a non-adjacent key is done as a series of moves to adjacent keys. It takes 2 seconds.
The program generates list of prime numbers for specific range.
The function is expected to return an INTEGER. The function accepts following parameters:
- INTEGER num - Range of prime number.
- INTEGER val - if the val = 1, return the odd indices of the prime number list, else if the val = 0, return the even indices of the prime number list.
This program implement a string method that takes five input parameters as follows:
- para: A long strings of text.
- special1: A string of special characters.
- special2: A single character.
- list1: A list of string.
- strfind: A single word to find
The string method are implemented as follows:
-
Remove all special characters from para specified in special1 and save them in the variable word1.
-
Get the first 70 character from word1, reverse the string, save it in variable rword2, and print it.
-
Remove all the Wide spaces from rword2, join the characters using the special character specified in special2, and print the joint string.
-
If every string from list1 present in para, then format the print statement as follows:
- "Every string in {list1} were present"
Else
- "Every string in {list1} were not present"
-
Split every word from word1 and print the first 20 strings as a list.
-
Calculate the less frequestly used words whose count < 3 and print the last 20 less frequent words as a list.
-
Print the last index in word1, where the substring strfind is found.
Import the 'itertools' module. Define a function called 'performIterator', which takes one parameter.
tuplevalues: It is a tuple. It always contains 4 tuples.
Generate the code based on following conditions:
-
Declare an emplty main list.
-
Declare another list. Use the cycle module of the itertools to cycle through the first tuple and append the values to the list.
- Convert the list into tuple and append it to the main list.
-
Use the repeat module in the itertools to repeat the first value from the second tuple.
- Create a tuple with the values and append it to the main list.
-
Use the accumulate module in the itertools to get the product after each iteration from the third tuple.
- Create a tuple with the values and append it to the main list.
-
Use the chain module in the itertools to chain all the values of the tuple.
- Create a tuple with the values and append it to the main list.
-
Use the filterfalse module in the itertools to extract the odd number from the chainned tuple.
- Create a tuple with the values and append it to the main list.
-
Convert the main list into a tuple and return it.
Import the calendar module. Define a function called 'usingcalendar' which takes following paramerer:
datetuple- a tuple of (year, month, date)
Generate the code based on following conditions:
-
Use the calendar module to build the code.
-
Check whether the given year from the tuple is a leap year.
- If it is a leap year, assign the month's value as 2 throughout the whole function.
-
Print the monthly calendar for the specified year and month.
-
Use itermonthdates module from the calendar to iterate through date of the specified month and year in the calendar.
- Print the last 7 days that appear on the calendar of that month as a list.
-
Print the day of the week, which appears the most frequent in the specified month and year as a string.
- The string can be
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. - If there is more than one frequent day, then consider the one that comes first.
- For example, if there are same number of Mondays and Tuesdays, then consider Monday.
- The string can be
Input Constraints
All the values must be integer.
Import the collections module. Define a function called collectionfunc which takes following six parameters:
text1: A string of sentence.dictionary1: A dictionary.key1: A list of keys.val1: A list of values.deduct: A distionary.list1: A list of keys.
Generate print statements based on following conditions:
-
Create a dictionary with the count of words in text1.
- The words must be the keys and the counts must be the values.
- Print the dictionary sorted by key.
-
Create a counter object using dictionary1.
- Subtract the values of the counter object from the respective values specified in the deduct dictionary.
- Convert the counter object into a dictionary and print it.
-
Create an ordered dictionary with key1 values as key and val1 values as value.
- Delete the key in the ordered dictionary using the second value from key1.
-
Reinsert the second values from key1 as key and val1 as value into the ordered dictionary.
- Convert the ordered dictionary into a normal dictionary and print the same.
-
Create a default dictionary that has 'even' and 'odd' keys.
- The keys must have in the list as their respective values.
- Extract the 'even' and 'odd' numbers from the list1.
- Print the default dictionary as a normal dictionary.
Import fernet from cryptography module. Define a function called encrdecr which takes 3 parameters as follows:
keyval: key for encoding and decoding data.textencr: Text to be encrypted.textdecr: The byte-code to be decrypted.
Write code based on the following conditions:
- Declare an empty main list.
- Encrypt the text in textencr and append it to the list.
- Decrypt the byte-code in textdecr and append it to the list.
- Return the list.
Import datetime module. Define a function called dateandtime which takes 2 parameters:
val: An Integer value ranges from 1 to 5.tup: A Tuple, whose values change based on the value of val.
Input Constraints
- When the value of val is 1 or 4, the tuple tup will contain three values in the order of (year, month, date) in the form of integers.
- When the value of val is 2, the tuple tup will contain one single integer value of timestamp.
- When the value of val is 3, the tuple tup will contain three values in the order of (hours, minutes, seconds) in the form of integers.
- When the value of val is 5, the tuple tup will contain six values in the order of (year, month, date hours, minutes, seconds) in the form of integers.
Develop the function based on following conditions:
-
Declare an empty list.
-
When the value of val is 1:
- Convert the tuple tup into date and append it into the list.
- Format the date in
%d/%m/%Yformat and append it into the list.
-
When the value of val is 2:
- Convert the tuple tup into date and append it into the list.
-
When the value of val is 3:
- Convert the tuple tup into time and append it into the list.
- Extract the hour in 00-12 format and append it into the list.
-
When the value of val is 4:
- Convert the tuple tup into date.
- From the date, extract the weekday (full version) and append it into the list.
- From the date, extract the month (full version) and append it into the list.
- From the date, extract the day number of the year (001 - 366) and append it into the list.
-
When the value of val is 5:
- Convert the tuple tup into datetime and append it into the list.
-
Return the list.