title-img


Lists

Consider a list (list = []). You can perform the following commands: 1. insert i e: Insert integer e at position i. 2. print: Print the list. 3. remove e: Delete the first occurrence of integer e . 4. append e: Insert integer e at the end of the list. 5. sort: Sort the list. 6. pop: Pop the last element from the list. 7. reverse: Reverse the list . Initialize your list and read in the value of n followed by n lines of commands where each comma

View Solution →

Time Conversion

Given a time in 12 -hour AM/PM format, convert it to military (24-hour) time. Note: - 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. - 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock. Example s = '12 : 01: 00PM' Return '12:01:00'. s = '12 : 01: 00AM' Return '00:01:00'. Function Description Complete the timeConversion function in the editor below. It should return a new string representing the input time in 24 hour format. timeConversion h

View Solution →

Grading Students

HackerLand University has the following grading policy: 1. Every student receives a grade in the inclusive range from 1 to 100. 2. Any grade less than 30 is a failing grade. Sam is a professor at the university and likes to round each student's grade according to these rules: 1.If the difference between the grade and the next multiple of 5 is less than 3 , round up to the next multiple of 5. 2.If the value of grade is less than 38 , no rounding occurs as the resul

View Solution →

Tuples

Task: Given an integer, n, and n space-separated integers as input, create a tuple, t, of those n integers. Then compute and print the result of hash(t). Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. Input Format: The first line contains an integer, n, denoting the number of elements in the tuple. The second line contains n space-separated integers describing the elements in tuple t. Output Format: Print the r

View Solution →

sWAP cASE

You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. For Example: Www.HackerRankSolution.in → wWW.hACKERrANKsOLUTION.IN Pythonist 2 → pYTHONIST 2 Input Format: A single line containing a string S. Constraints: 0<len(S)<=1000 Output Format: Print the modified string S.

View Solution →