While taking a viva class teacher decides to take the viva of two roll numbers at a time.
For this she calls the roll numbers from roll numbers list as : one roll number from 1st nth roll number and 2nd roll number from the nth last roll number. For example if the numbers are : roll-num=[21,23,45,6,7,23,9,11,15,18] and n=3. One roll number calls 45 for viva and
second roll number called 11 for viva. Write a python function CRN(X, n) which take a list X and nth roll no. as input and returns 1st nth roll no. and 2nd roll no. from nth last roll no.
If nth roll number does not lie in range of the list the function will return "n not in range" in place of 1st roll no. and empty string " " in place of 2nd roll number. Give fixed input .
Convert the Number
Given a number having ten digits, convert it to a string following the below-mentioned rules.
Rules for conversion:
1.separate the number into a set of four-three-three digits
2.Use the following prefixes for successive digits
a.Single numbers: just read them separately
b.Two consecutive numbers: double
c.Three consecutive numbers: triple
d.Four consecutive numbers: quadruple
Input
The first line of input is a string of ten digits.
Sample Input1
9887666668
sample Output1
nine double eight seven triplesix double six eight
Sample Input2
9090407368
Sample Output2
nine zero nine zero four zero seven three six eight
For a certain academic subject the students are evaluated based on five tests -
Design a program that will prompt the user for marks for each of the tests and calculate the overall marks (out of 100).
Write a program that has two functions: the main function and a function, called sumOfSquared(n), that takes an integer number (read in the main function uisng input) and calculates the total sum of squares of all numbers from 1 to a given number. Then, it returns the result to the main function. Finally, the result should be printed.
Final Project - TicTacToe Human vs. Computer 2 # 3 # Purpose: using a nested list structure to store a 3x3 grid of values 4 # simulate a childhood game of tic-tac-toe. The human player interacts 5 # with a full command line interface to select board positions.
Area of a Sub-matrix
You are given an M*N matrix and K, write a program to compute the area of the sub-matrix and print the result.
A sub-matrix is a matrix formed after deleting K rows each from the top and bottom and K columns each from left and right.
Area of a matrix is defined as the product of all elements of the matrix.
Explanation
For M = 5 and N = 4, the matrix is:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
For K = 1, the sub-matrix is as follows:
6 7
10 11
14 15
Therefore, the area of the matrix is 6*7*10*11*14*15 = 970200.
Sample Input1
5 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
1
Sample Output1
970200
New Dictionary
Peter is making a new dictionary.He wants to arrange the words in the ascending order of their length and later arrange the ones with the same length in lexicographic order.Each word is given a serial number according to its position.Find the word according to the serial number.
Input
The first line of input is a positive integer which is the serial number.
Output
The output should be a single line containing the word that represents the serial number.
Explanation
Given serial number is 42.
As the serial number is between 26 and 52, the first character of the word is A.The remaining counter of the serial number is 16 (42-26).
The second character of the word is the 16th alphabet, which is P.
So, the output should be AP.
Sample Input1
42
Sample Output1
AP
Sample input2
751
Sample output2
ABW
The volume of a sphere is 4/3πr3, where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called print_volume (r) that takes an argument for the radius of the sphere, and prints the volume of the sphere.
Call your print_volume function three times with different values for radius.
Include all of the following in your Learning Journal:
Product of the String
You are given an alphanumeric string S.Write a program to multiply all the charcters(except trailing zeroes) in S and print the output.
Rules for multiplication:
Input
The first line contains a string S.
Output
The output should be a integer denoting the product of characters.
Explanation
For N = 123a4
ASCII value of a is 97.
Product of digits of ASCII value of a is 9 *7 = 63.
Therefore the product of characters is 1*2*3*4*63*4 = 1512.
Sample Input1
123a4
Sample Output1
1512
write a python function Separate_List(A) (Refer RollNo_W8B_2.py ) which take list A as input and return five lists, one contains all prime numbers in A, second one contains composite numbers in A, the third list contains all numbers in A which are neither divisible by 2, fourth and fifth list contains number divisible by 3 and 5