Q1) PROGRAM TO OBTAIN THREE NUMBERS AND PRINT THEIR SUM:-
LINE 1 , 2 AND 3 :-HERE IN EACH LINE I HAVE USED INT SO THAT ONLY NUMERIC VALUES CAN BE TAKEN AS THE INPUT VALUE SO THAT WE CAN ADD THEM.
LINE 4 :-HERE I HAVE TAKEN "SUM"AS A VARIABLE WHERE WE ARE PERFORMING ADDITION OF THE THREE NUMBERS WHICH ARE TO BE TAKEN FROM THE USER.
LINE 5:-HERE I AM PRINTING THE SUM OF THAT THREE NUMBERS AND ALSO A STATEMENT ABOUT THAT -"TOTAL OF THE 3 NUMBERS IS..."THIS IS A DESCRIPTION ABOUT WHAT IS THE NUMBER ABOUT AND ALL IT IS OPTIONAL .YOU CAN SIMPLY WRITE print(sum).
TRY IT YOURSELF !! :-
num1 = int (input('Enter the first number:')) num2 = int (input('Enter the second number:')) num3 = int (input('Enter the third number:')) sum=num1+num2+num3 print('The total of the three numbers is:' ,sum)
Q2) PROGRAM TO OBTAIN LENGTH AND BREADTH OF A RECTANGLE AND CALCULATE ITS AREA:-
HERE I HAVE DO TAKE LENTH AND BREADTH FROM THE USER THEREFORE I HAVE USED INPUT FUNCTION . THEN AREA I HAVE TAKEN AS A VARIABLE TO MULTIPLY LENGTH AND BREADTH AND GET THEIR AREA . HERE THE POIN IS END=" "THIS MEANS THAT I WANT A SPACE AFTER THE LENGTH IS DISPLAYED AND BREADTH IS DISPLAYED.
TRY IT YOURSELF !! -
No comments:
Post a Comment