Programming
Fundamentals - II
using Python 🐍
Lecture
Problem Solving Practice
- break & continue
- branching
- looping
- coding problems

Loops
Do something again & again!

break
continue
pass
return
Switch Match Case
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!");
}
}
}
No Do While Loop

Code Demo!
Number Sum

Find the sum of even numbers from 1 to N using for loop.
Example
N = 4
Output
10
Triangle Pattern

Print the given Pattern.
Example
N = 4
Output
*
**
***
****
Half Diamond

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
Largest Number

Print all Primes

Given a and b, print all primes in the range [a,b]
Input
1 10
Output
2,3,5,7
Count Digits

Given a integer, count the digits
Input
215
Output
3
Time To Try!



8 Mins
Reverse a Number

Given a integer, reverse the number.
Input
215
Output
512
Reverse a Number

Given a integer, reverse the number.
Input
215
Output
512
[Python 05] Programming Fundamentals - II
By Prateek Narang
[Python 05] Programming Fundamentals - II
- 10