## Write a function

An extra day is added to the calendar almost every four years as February 29, and the day is called a leap day. It corrects the calendar for the fact that our planet takes approximately 365.25 days to orbit the sun. A leap year contains a leap day. In the Gregorian calendar, three conditions are used to identify leap years: 1.The year can be evenly divided by 4, is a leap year, unless: 2.The year can be evenly divided by 100, it is NOT a leap year, unless: 3.The year i

View Solution →## Print Function

The included code stub will read an integer, n, from STDIN. Without using any string methods, try to print the following: 123...n Note that "" represents the consecutive values in between. Example: n=5 Print the string 12345. Input Format: The first line contains an integer n. Constraints: 1<=n<=150 Output Format: Print the list of integers from 1 through n as a string, without spaces.

View Solution →## List Comprehensions

Let's learn about list comprehensions! You are given three integers x,y and z representing the dimensions of a cuboid along with an integer i. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0<=i<=x; 0<=j<=y; 0,=k<=z. Please use list comprehensions rather than multiple loops, as a learning exercise. Example: x=1 y=1 z=2 n=3 All permutations of [i,j,k] are: . [[0,0,0], [0,0,1], [0,0,2],

View Solution →## Find Runne-Up Score

Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given n scores. Store them in a list and find the score of the runner-up. Input Format: The first line contains n. The second line contains an array A[] of n integers each separated by a space. Constraints: 2<=n<=10 -100<=A[i]<=100 Output Format: Print the runner-up score.

View Solution →## Nested Lists

Given the names and grades for each student in a class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line. Example: records=[["chi",20.0], ["beta", 50.0], ["alpha",50.0]] The ordered list of scores is [20.0,50.0] , so the second lowest score is 50.0. There are two students with that s

View Solution →