Programming Answers
1. What is flowchart? Explain with one example.
A Flowchart is a pictorial representation of step by step solution for a specific
[Link] consist symbols that represent meaning and arrows that shows the flow
of the direction that the program takes [Link] will show about what the problem is
going to do and how it is going to do it.
Symbols that represents the actions are:
User performing
Start/Stop
tasks
Decision
Flow-Arrows
Action
Example for a Flow chart:
Start
Result=10+10
Display Result
Stop
[Link] a pseudo code for following :
Input 2 numbers from keyboards and find the maximum.
Step 1 : Start
Step 2: Input num1,num2
Step 3: If num1 > num2
Display num1
Else
Display num2
Step 4: Stop
[Link] is function in python ? how can you call a function? explain with example.
Function is a group of statement that performs a specific task which helps the user to
reduce line of codes into a small sections with more organized and in a manageable
way.A user can define a function and then call the function to perform a specific
[Link] we are calling a function we have to pass the argument.
For Example:
#when we are to define a function
def add (x,y):
return x+y;
#we have to take the value from the user
x= int(input(“x = ”))
y= int(input(“y = ”))
#calling a function
print=(“Total is : ” ,add(x,y))
Output
4. What are arguments? Explain with a program using python.
Arguments are constructed with parameters which are used to specify what argument
does a function requires when it is [Link] the user calls a function each
parameters will be assigned to one of the argument value.
For Example:
def add(x,y):
return x+y;
z= add (4,6)
Print(“Total :”,z)
Here there are two arguments which are 4 and 6 that is given for [Link] first
argument that is assigned for first parameter is x and the second one is y.
[Link] is a constructor? What are the different types of constructors available?
explain with examples.
Constructor is defined as a special type of method/function that can be used to
initialize various members in a class and There are two types of constructors which
are:
Parameterized: A constructor that has a pre-defined parameter.
For Example:
class Staffs:
def __init__(own, fname, lname):
[Link] = fname
[Link] = lname
def display(own):
print("Hi", [Link], [Link])
Staffs = Staffs("Peter", "David")
[Link]()
Output:
Hi Peter David
Process finished with exit code 0
Non Parameterized: A constructor that has no parameters at present.
class Staffs:
def display(self, fname, lname):
print("Hi", fname, lname)
Staffs = Staffs()
[Link]("Peter", "David")
Output:
Hi Peter David
Process finished with exit code 0