Document 12

You might also like

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

Difficulty Level 2 (Very Easy):

1.Checks whether a given number is positive or negative. If the given number is positive then it will
print “Positive”. Displays “Negative” if it is negative and displays “Zero” if it is zero;

Algorithm

Step 1: Start

Step 2: Input num

Step 3: if num > 0:

print("It is a positive number.")

elif num < 0:

print("It is a negative number.")

else:

print("It is zero.")

Step 4: Stop
2. asks a number from the user and generates an integer between 1 and 7 and displays the name of the
weekday.

Otherwise, displays “Unknown weekday!”;

Algorithm

Step 1: Start

Step 2: Input num

Step 3: if num == 1:

print ("Weekday is Monday")

elif num == 2:

print("Weekday is Tuesday")

elif num == 3:

print("Weekday is Wednesday")

elif num == 4:

print("Weekday is Thirsday")

elif num == 5:

print("Weekday is Friday")

elif num == 6:

print("Weekday is Saturday")

elif num == 7:

print("Weekday is Sunday")

else:

if num > 7:

print("Unknown Weekday!")

Step 4: Stop
3. checks whether a given number is even or odd. If the given number is even then it will print "Even
number".Prints "Odd number" if the given number is odd. Otherwise, it will print "Zero" if the given
number is zero.

3. Step 1: Start

Step 2: Input num

Step 3: if if num % 2 == 0 and num != 0:

print(f'Even number')

elif num % 2 != 0 and num != 0:

print(f'Odd number')

else:

print("Zero")

Step 5: Stop
4. finds whether a given year is a leap year or not. If the given year is leap year, then it will print "Leap
year".

Prints "Not leap year" otherwise;

Step 1: Start

Step 2: Input year

Step 3:if year % 4 == 0 and year % 2000 !=0 or year % 2000 == 0:

Print(‘Leap year’)

Else:

Print(‘Not leap year’)

Step 4: Stop
5. determines whether a given number is divisible by 3 or 5; If the given number is divisible by 3 or 5
then it will print "Divisible by 3 or 5". Prints "Not divisible by 3 or 5" otherwise;

Step 1: Start

Step 2: Input num

Step 3: if num % 3 == 0 and num % 5 == 0:

print('Divisible by 3 and 5')

else:

print('Not divisible by 3 or 5')

Step 4: Stop
6. accepts three numbers from the user and prints "Increasing order" if the numbers are in increasing
order, "Decreasing order"

if the numbers are in decreasing order, and "Neither increasing or decreasing order" otherwise;

Step 1: Start

Step 2:Input a, b ,c

Step 3: if a < b < c:

Print(‘Increasing order’)

Elif a > b > c:

Print(‘Decreasing order’)

Else:

Print(‘Neither increasing or decreasing order’)

Step 4: Stop
7. checks whether a triangle is Scalene, Isosceles, or Equilateral;

Step 1. Start

Step 2. Input side1, side2, side3

Step 3. if side1 == side2 and side2 == side3 and side1 == side3:

Print(“It’s an Equilateral Triangle”)

Elif side1 == side2 or side2 == side3 or side1 == side3:

Print(“It’s an Isosceles Triangle “)

Else:

Print(“It’s a Scalene Triangle”)

Step 4. Stop
8. reads two numbers and displays these numbers in increasing order. If these numbers are equal, then
it will print "They are equal";

Step 1. Start

Step 2. Input a, b

Step 3. list1 = [a, b]

List1.sort()

Step 4. Print list1

Step 5. Stop
9. accepts three numbers and determines the largest number;

Step 1. Start

Step 2. Input a, b, c

Step 3. lista = [a, b, c]

Step 4. Print max(lista)


10. inputs two term grades of a major subject and displays the final grade and remark accordingly. If
final grade is below 75 then

Remark is “Failed”. If final grade is 75 to 79 then remark is “Retake”. Otherwise, the remark is “Passed”
if final grade is 80 and above;

Step 1. Start

Step 2. Input firstTerm, lastTerm

Step 3. finalGrade = (firstTerm + lastTerm)/2

Step 4. Print finalGrade

Step 5.if finalGrade < 75:

Print(“Remark: Failed”)

Elif finalGrade < 79 and finalGrade == 75:

Print(“Remark: Retake”)

Else:

Print(‘Remark: Passed’)
Step 6. Stop

Difficulty Level 3 (Easy):

1. Prints the SUM of numbers from LOW to HIGH;

Step 1. Start

Step 2. Input Low, High

Step 3. Total = 0

Step 4. Set I = Low

Step 5. While I <= High:

a. Total += i

b. I += 1

Step 6. Print Total

Step 7. Stop
2. Prints the cube of all the numbers between LOW to HIGH; (print the result in comma-separated
style)

Step 1. Start

Step 2. Input low, high

Step 3. Set I = low

Step 4. While I <= high:

a. Print I * I * i

b. If I is not the last number in the range, print a comma

c. I += 1

Step 5. Stop
3. prints all numbers that are not divisible by 5 between HIGH down to LOW; (print the result in comma-
separated style)

Step 1. Start

Step 2. Input high, low

Step 3. for I in range(high, low-1, -1):

If I % 5 != 0:

Print(I, end=”,”)

Step 4: Stop
4. prints all numbers from LOW to HIGH that are divisible by 3 or 4; (print the result in comma-separated
style)

Step 1. Start

Step 2. Input low, high

Step 3. I = low

Step 4. I <= high

Step 5. if true proceed to next step otherwise go to step 9

Step 6. if I % 3 == 0 or I % 4 == 0

Step 7. if true proceed to next step otherwise go back to step 4

Step 8. Print I, end = “,”

Step 9. go back to step 4.

Step 10. Stop


5. prints all numbers between LOW to HIGH that are both divisible by 2 and 3; (print the result in
comma-separated style)

Step 1. Start

Step 2. Input low, high

Step 3. I = low

Step 4. I <= high

Step 5. if true proceed to next step otherwise go to step 10

Step 6. if I % 2 == 0 and I % 3 == 0

Step 7. if true proceed to next step

Step 8. print I , end = “,”

Step 9. go back to step 4

Stel 10. Stop


6. prints all numbers from LOW to HIGH that are divisible by NUMBER; (print the result in comma-
separated style)

Step 1. Start

Step 2. Input low, high, number

Step 3. for I in range(low, high+1):

If I % number == 0:

Print(I, end=”,”)

Step 4. Stop
7. prints all odd numbers between HIGH down to LOW; (print the result in comma-separated style)

Step 1. Start

Step 2. Input high, low

Step 3. for I in range(high, low-1, -1):

If I % 2 != 0:

Print(I, end=’,’)

Step 4. Stop
8. prints all even from LOW to HIGH; (print the result in comma-separated style)

Step 1. Start

Step 2. Input low, high

Step 3. for I in range(low, high+1):

If I % 2 == 0:

Print(I, end=”,”)

Step 4.Stop
9. prints all numbers between LOW to HIGH by steps of STEP; (print the result in comma-separated
style)

Step 1. Start

Step 2. Input low, high, step

Step 3. for I in range(low, high+1, step):

Print(I, end=”,”)

Step 4. Stop
10. prints all numbers between HIGH down to LOW by steps of STEP. (print the result in comma-
separated style)

Step 1. Start

Step 2. Input high, low, step

Step 3. for I in range(high, low-1, -step):

Print(I, end=”,”)

Step 4. Stop

You might also like