Page 338 - Artificial Intellegence_v2.0_Class_9
P. 338
Calculate the percentage
Display the percentage
2. Explain the important symbols of flowchart.
Ans. Oval Used to start and end a flowchart.
Parallelogram Used for input and output operation.
Rectangle Used for assignment, mathematical operations, processing
Diamond Used for decision making in case of branching or looping.
Arrow Used for to show the direction of flow of information.
3. Explain the use of print( ) function with all its parameters.
Ans. The print() function is used to print an output on the screen. It converts the expressions into a string before writing to
the screen. Syntax to use the print( ) function is:
print(object(s), sep = separator, end = end)
Where,
• object can be one or more separated by comma and it can be a variable, literal, expression. An object will be
converted to string before printed.
• sep is used as a separator if there are more than one objects.
• end specifies what to print at the end. Default is newline '\n'.
4. Give two different ways of writing statements in Python.
Ans. • Simple statements: By default, the end of a statement is done by pressing an Enter key. Each statement is
written on a new line.
a=5 is a simple statement where variable-a is created with value 5.
c=a + b
• Multiline Statements: We can make a statement that extends over multiple lines by using line continuation
character (\) as shown below:
a = 4 + 5 +\
6 + 7 +\
8 + 9
The main advantage of using multiline is when we need to do long calculations and cannot fit these statements into
one line.
5. Explain if…else statement with example.
Ans. When the condition is True then the statements indented just below the if statement will be executed and if the
condition is False then the statements indented just below the else statement will be executed. Syntax is:
if (condition):
Statements for True
else:
Statements for False
Example:
age=input("enter your age ")
if (age>=18):
336 Touchpad Artificial Intelligence (Ver. 2.0)-IX

