| Medium ZeroDivisionError and IndexError | 2 mins Python | Solve |
What will the following Python code output?
|
| Medium Session | 2 mins Python | Solve |
The function high_sess should compute the highest number of events per session of each user in the database by reading a comma-separated value input file of session data. The result should be returned from the function as a dictionary. The first column of each line in the input file is expected to contain the user’s name represented as a string. The second column is expected to contain an integer representing the events in a session. Here is an example input file:
Tony,10
Stark,12
Black,25
Your program should ignore a non-conforming line like this one.
Stark,3
Widow,6
Widow,14
The resulting return value for this file should be the following dictionary: { 'Stark':12, 'Black':25, 'Tony':10, 'Widow':14 }
What should replace the CODE TO FILL line to complete the function?
|
| Medium Max Code | 2 mins Python | Solve |
Below are code lines to create a Python function. Ignoring indentation, what lines should be used and in what order for the following function to be complete:
|
| Medium Recursive Function | 3 mins Python | Solve |
Consider the following Python code:
In the above code, recursive_search is a function that takes a dictionary (data) and a target key (target) as arguments. It searches for the target key within the dictionary, which could potentially have nested dictionaries and lists as values, and returns the value associated with the target key. If the target key is not found, it returns None.
nested_dict is a dictionary that contains multiple levels of nested dictionaries and lists. The recursive_search function is then called with nested_dict as the data and 'target_key' as the target.
What will the output be after executing the above code?
|
| Medium Stacking problem | 4 mins Python | Solve |
What does the below function ‘fun’ does?
A: Sum of digits of the number passed to fun.
B: Number of digits of the number passed to fun.
C: 0 if the number passed to fun is divisible by 10. 1 otherwise.
D: Sum of all digits number passed to fun except for the last digit.
|
| Medium Multi Select | 2 mins SQL | Solve |
Consider the following SQL table:
How many rows does the following SQL query return?
|
| Medium nth highest sales | 3 mins SQL | Solve |
Consider the following SQL table:
Which of the following SQL commands will find the ‘nth highest Sales’ if it exists (returns null otherwise)?
|
| Medium Select & IN | 3 mins SQL | Solve |
Consider the following SQL table:
Which of the following SQL queries would return the year when neither a football or cricket winner was chosen?
|
| Medium Sorting Ubers | 3 mins SQL | Solve |
Consider the following SQL table:
What will be the first two tuples resulting from the following SQL command?
|
| Hard With, AVG & SUM | 2 mins SQL | Solve |
Consider the following SQL table:
How many tuples does the following query return?
|
| Easy Registration Queue | 30 mins Coding | Solve |
We want to register students for the next semester. All students have a receipt which shows the amount pending for the previous semester. A positive amount (or zero) represents that the student has paid extra fees, and a negative amount represents that they have pending fees to be paid. The students are in a queue for the registration. We want to arrange the students in a way such that the students who have a positive amount on the receipt get registered first as compared to the students who have a negative amount. We are given a queue in the form of an array containing the pending amount.
For example, if the initial queue is [20, 70, -40, 30, -10], then the final queue will be [20, 70, 30, -40, -10]. Note that the sequence of students should not be changed while arranging them unless required to meet the condition.
⚠️⚠️⚠️ Note:
- The first line of the input is the length of the array. The second line contains all the elements of the array.
- The input is already parsed into an array of "strings" and passed to a function. You will need to convert string to integer/number type inside the function.
- You need to "print" the final result (not return it) to pass the test cases.
For the example discussed above, the input will be:
5
20 70 -40 30 -10
Your code needs to print the following to the standard output:
20 70 30 -40 -10
|
| Medium Visitors Count | 30 mins Coding | Solve |
A manager hires a staff member to keep a record of the number of men, women, and children visiting the museum daily. The staff will note W if any women visit, M for men, and C for children. You need to write code that takes the string that represents the visits and prints the count of men, woman and children. The sequencing should be in decreasing order.
Example:
Input:
WWMMWWCCC
Expected Output:
4W3C2M
Explanation:
‘W’ has the highest count, then ‘C’, then ‘M’.
⚠️⚠️⚠️ Note:
- The input is already parsed and passed to a function.
- You need to "print" the final result (not return it) to pass the test cases.
- If the input is- “MMW”, then the expected output is "2M1W" since there is no ‘C’.
- If any of them have the same count, the output should follow this order - M, W, C.
|