Problem Solving Practice
Do something again & again!
in Python 3.10 or higher
class HelloWorld {
public static void main( String args[] ) {
int weather = 2;
//passing variable to the switch
switch (weather)
{
//comparing value of variable against each case
case 0:
System.out.println("It is Sunny today!");
break;
case 1:
System.out.println("It is Raining today!");
break;
case 2:
System.out.println("It is Cloudy today!");
break;
//optional
default:
System.out.println("Invalid Input!");
}
}
}
Find the sum of even numbers from 1 to N using for loop.
Example
N = 4
Output
10
Print the given Pattern.
Example
N = 4
Output
*
**
***
****
Print the pattern for given N.
Example
N = 3
Output
*
***
*****
Given N numbers, find the largest number.
Sample Input
N = 7
10, 20, 30, 400, 50, 20, 70
Sample Output
400
Given a and b, print all primes in the range [a,b]
Input
1 10
Output
2,3,5,7
Given a integer, count the digits
Input
215
Output
3
8 Mins
Given a integer, reverse the number.
Input
215
Output
512
Given a integer, reverse the number.
Input
215
Output
512