Python Pseudocode Program | swapping the number,marks of students

 



Python Pseudocode Program


Pseudocode is not programming language ,it is very useful and helpful tool in algorithm development.

Advantages:

It offers many advantages and it has some disadvantages.

It uses a language similar to eceryday English ,thus is easy to understand.

The structure of an algorithm is clearly visible through pseudocode ,eg.selection and repetition blocks.


Disadvantages:

It is not visual tool like flowcharts.

It can only be tested on paper ,there is no program available to test it.

It is an informal representation of an algorithm.

So now we will do some program using pseudocode.

Q.Writing pseudocode for swapping of two numbers without using third variable in Python
Python pseudocode to calculate total marks of students


Testcases1:

1

2


Output:

2

1

Testcases2:

35

87

Output:

87

35

#This is in Pseudocode
#Write a Pseudocode  to swap the numbers without using third variable 
#This program we are writing to understand the program in Pseudocode
#Now we will take input i.e N1 and N2 boths value

INPUT N1, N2
#Then We will print both number before swapping
Print(N1,N2)

#Now we are swapping the values using assignment operator
N1,N2=N2,N1

# Then print values after intercahnging their values
Print(N1,N2)




#Now in Correct Way in Python

#Write a Program to swap the numbers without using third variable 
#First  program we are writing to understand the program
#Now we will take input i.e N1 and N2 boths value using input() function and then type caste in integer using int() function

N1=int(input("Enter a first number:"))
N2=int(input("Enter a second number:"))
#Then We will print both number before swapping using print() function
Print("Before swapping the two number ",N1,N2)

#Now we are swapping the values using assignment operator
N1,N2=N2,N1

# Then print values after interchanging their values using print()
Print("After swapping the two numbers",N1,N2)



Q.Write Python pseudocode to calculate total marks of students

Testcases1:

98

97

97

89

90


Output:

481

Testcases2:

98

100

54

78

89

Output:

419



Write Python pseudocode to calculate total marks of students

#Write pseudocode to calculate marks of students
#First  program we are writing to understand the program
INPUT S1,S2,S3,S4,S5

#Then we calculate the sum of all the Students
sum =S1+S1+S3+S4+S5
# Then print sum of the marks of all students

Print(sum)



#Correct way to write in python

#Write a program to calculate marks of all students
#First  program we are writing to understand the program
#Input marks of all the students using input() function and use int() function to type caste in integer
S1=int(input("Enter a marks of the first students:"))
S2=int(input("Enter a marks of the second students:"))
S3=int(input("Enter a marks of the third students:"))
S4=int(input("Enter a marks of the fourth students:"))
S5=int(input("Enter a marks of the fifth students:"))
#Then we calculate the marks  of all the Students
sum =S1+S1+S3+S4+S5
# Then print sum of the marks of all students using print()

Print(sum)



















No comments:

Powered by Blogger.