Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Q1 Python If-Else

Task
Given an integer,n , perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of to , print Not Weird
If n is even and in the inclusive range of to , print Weird
If n is even and greater than , print Not Weird
Input Format
A single line containing a positive integer, n .
Constraints
1 <= n <= 100
Output Format
Print Weird if the number is weird; otherwise, print Not Weird .
Sample Input 0
3
Sample Output 0
Weird
Sample Input 1
24
Sample Output 1
Not Weird
Sample Input 0
3
Sample Output 0
Weird
Explanation 0
n = 3
n is odd and odd numbers are weird, so we print Weird .
Sample Input 1
Check Tutorial tab to know how to to solve.
24
Sample Output 1
Not Weird
Explanation 1
n = 24
n > 20 and n is even, so it isn't weird. Thus, we print Not Weird .

Q2 Read an integer N . For all non-negative integers i<N , print i*i . See the
sample for details.

Input Format

The first and only line contains the integer, N.

Constraints
1 <= N <= 20

Output Format

Print N lines, one corresponding to each i .

Sample Input 0
5
Sample Output 0

0
1
4
9
16

Q3 Given the names and grades for each student in a Physics 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 same grade, order their names
alphabetically and print each name on a new line.

Input Format

The first line contains an integer, N, the number of students.


The 2n subsequent lines describe each student over 2 lines; the first line contains
a student's name, and the second line contains their grade.

Constraints
1 <= N <= 5
There will always be one or more students having the second lowest grade.
Output Format

Print the name(s) of any student(s) having the second lowest grade in Physics; if
there are multiple students, order their names alphabetically and print each one on
a new line.

Sample Input 0

5
Harry
37.21
Berry
37.21
Tina
37.2
Akriti
41
Harsh
39
Sample Output 0

Berry
Harry
Explanation 0
There are 5 students in this class whose names and grades are assembled to build
the following list:

python students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti',


41], ['Harsh', 39]]

The lowest grade of 37.2 belongs to Tina. The second lowest grade of 37.21 belongs
to both Harry and Berry, so we order their names alphabetically and print each name
on a new line.

Q4 Write a program to find 3 maximum number

Example input:102,1,5,8,93,27,92
output :92

Q5
Write a program to find the Phone number is valid or not ?

Q6.Write a program for printing any number entered by the user to print in words.
Example
99 -->
ninety nine
300 -->
three hundred
310 -->
three hundred and ten
1501 -->
one thousand, five hundred and one
12609 -->
twelve thousand, six hundred and nine
512607 -->
five hundred and twelve thousand,
six hundred and seven
43112603 --> forty three million, one hundred and
twelve thousand,
six hundred and three

While writing the program consider following points


1. Write all the programs in generic way means it should work with any input, if
you are giving wrong input it should prompt wrong input.
2. Use exception handling
3. Use functions.
4. Write a proper documentaion
5. Variable name declarations has to be self explinatory.

Al the best Guys

You might also like