This document contains all the intermediate exercises. If you find an error or a bug or something that could be written better, please get in contact with me. Thanks.
Write a program that calculates and prints the value according to the given formula:
Q = Square root of [(2 * C * D)/H]
Following are the fixed values of C and H:
-
C is 50. H is 30.
-
D is the variable whose values should be input to your program in a comma-separated sequence.
Example:
Let us assume the following comma separated input sequence is given to the program: 100,150,180
The output of the program should be: 18,22,24
Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i=0,1.., X-1; j=0,1,¡Y-1.
Example
Suppose the following inputs are given to the program: 3,5
Then, the output of the program should be: [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]
Note: In case of input data being supplied to the question, it should be assumed to be a console input in a comma-separated form.
Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated sequence after sorting them alphabetically.
Suppose the following input is supplied to the program:
without,hello,bag,world
Then, the output should be:
bag,hello,without,world
In case of input data being supplied to the question, it should be assumed to be a console input.
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
Suppose the following input is supplied to the program:
Hello world Practice makes perfect
Then, the output should be:
HELLO WORLD PRACTICE MAKES PERFECT
In case of input data being supplied to the question, it should be assumed to be a console input.
Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
Suppose the following input is supplied to the program:
hello world and practice makes perfect and hello world again
Then, the output should be:
again and hello makes perfect practice world
Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence.
Example: 0100,0011,1010,1001
Then the output should be: 1010
Notes: Assume the data is input by console.
In case of input data being supplied to the question, it should be assumed to be a console input.
Write a program, which will find all such numbers between 100 and 300 (both included) such that each digit of the number is an even number. The numbers obtained should be printed in a comma-separated sequence on a single line.
In case of input data being supplied to the question, it should be assumed to be a console input.
Write a program that accepts a sentence and calculate the number of letters and digits.
Suppose the following input is supplied to the program:
hello world! 123
Then, the output should be:
LETTERS 10 DIGITS 3
In case of input data being supplied to the question, it should be assumed to be a console input.