Python Programing Lab EXERCISE - 3(a)

Aim: 

                Write a Program for checking whether the given number is a even number or not.
Description: 
                            If a number is exactly divisible by 2(Remainder is 0) then it is said to be an Even number otherwise, the number is said to be an Odd number. In Python, We use modulus(%) operator to find the remainder. 

                            Decision making is used to specify the order in which the statements are executed. We can use if…else statement to check whether the number is even or odd.
if…else statement: 
                                   This is a two-way decision making statement that decides what to do when the condition is true and what to do when the condition is false. The general form of if…else statement is as followes: 

                                   if condition: 
                                           intended statement block for true condition 
                                    else: 
                                           intended statement block for false condition

Algorithm:

Input: A Number


Output: A Message 


Step1: Start 

Step2: Read num 

Step3: Check whether the num is divisible by 2 or not. If yes, goto Step4. else, goto Step5 

Step4: Display “The number is even” and goto step6 

Step5: Display “The number is odd" 

Step6: Stop

Program:

n=int(input("Enter a number---->"))
if n % 2 == 0:
          print ("EVEN Number");
else:

          print ("ODD Number");

Output:



2 comments

  1. Typo error in syntax of if...else statement
    Its "indented"

    ReplyDelete

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...