Familiarisation with Python

ICSE Class 9 Robotics & AI · Solutions for Class 9 ICSE Exploring Robotics & Artificial Intelligence · 29 solved questions

Exercise
Marks
11 Mark · Multiple Choice Questions

Which of the following programming languages is depicted by the given clip?

Which of the following programming languages is depicted by the given clip. Familiarisation with Python, APC ICSE Robotics & Artificial Intelligence Solutions Class 9.
Show SolutionHide Solution↓

Python

Reason — The picture depicts the official logo of Python programming language, which consists of two intertwined snakes in blue and yellow colours.

21 Mark · Multiple Choice Questions

In Object Oriented Programming, the emphasis is laid on ...............

Show SolutionHide Solution↓

data

Reason — In Object Oriented Programming, the emphasis is put on the data values rather than functions. The data values are confined and used within the stipulated programming area to encourage data security.

31 Mark · Multiple Choice Questions

............... is known as creator of Python.

Show SolutionHide Solution↓

Guido van Rossum

Reason — Guido van Rossum, who holds a Master's degree in Mathematics and Computer Science from the University of Amsterdam, Netherland, is regarded as the creator of Python. He named his project 'Python' in the year 1991.

41 Mark · Multiple Choice Questions

In Python, ............... mode is used to write a program file.

Show SolutionHide Solution↓

Script

Reason — Script mode is used only when the user needs to create a program file. In this mode, the user can save the complete set of instructions in a program file.

51 Mark · Multiple Choice Questions

In which language is Python written?

Show SolutionHide Solution↓

C

Reason — Python is a general-purpose interpreted, interactive high-level programming language written in C programming language.

61 Mark · Multiple Choice Questions

All keywords in Python are defined in ...............

Show SolutionHide Solution↓

lowercase letters

Reason — In Python, all the keywords (except True, False and None) are in lowercase and they must be written as it is, since Python is a case-sensitive language.

71 Mark · Multiple Choice Questions

Which of the following is not a Python keyword?

Show SolutionHide Solution↓

right

Reason — The words 'true', 'false' and 'not' are reserved keywords in Python which carry special meaning for the language translator. However, 'right' is not a Python keyword and can be used as an identifier.

81 Mark · Multiple Choice Questions

Which is the default Python command prompt?

Show SolutionHide Solution↓

>>>

Reason — The default Python command prompt is represented by three greater-than signs (>>>). It appears in the interactive mode where the user can type a statement and instantly obtain the output.

1Fill blanks

Fill in the blanks:

Show SolutionHide Solution↓
  1. Python language is object oriented programming language.
  2. An identifier may be a function name, a class name or a variable name.
  3. PySoy is a 3D game engine which enables the users to develop interactive games.
  4. Python is a fourth generation programming language.
  5. Escape sequences are some non-graphic characters which are used as commands in programs.
  6. Python has come from BBC's popular TV show Monty Python's Flying Circus.
1Evaluate the following expressions

Evaluate the following expressions:

Given: a=5; b=4

Show SolutionHide Solution↓
  1. 12*(a+b)-10
    = 12*(5+4)-10
    = 12*9-10
    = 108-10
    = 98

  2. 12*a+b-10
    = 12*5+4-10
    = 60+4-10
    = 64-10
    = 54

  3. 12+a*b-10
    = 12+5*4-10
    = 12+20-10
    = 32-10
    = 22

  4. 12-10+a*b
    = 12-10+5*4
    = 12-10+20
    = 2+20
    = 22

1Write down the escape sequences

Write down the escape sequences for the following:

DescriptionEscape Sequences
Horizontal tab
Backslash
Single quote
Double quote
Backspace
New line feed
Show SolutionHide Solution↓
DescriptionEscape Sequences
Horizontal tab\t
Backslash\
Single quote'
Double quote"
Backspace\b
New line feed\n
1Assertion and Reason based question

Assertion (A): Python works in two different modes. These modes are used as per the need of the user while performing the tasks.

Reason (R): Interactive mode refers to the mode where the user is able to see the instant output for the given input. Whereas, the script mode is used only when the user needs to make a program file.

Based on the above discussion, choose an appropriate statement from the options given below:

Show SolutionHide Solution↓

Both A and R are true and R is the correct explanation of A.

Reason — Python works in two different modes namely Interactive mode and Script mode. The interactive mode allows the user to obtain instant output by typing a command at the Python prompt (>>>) and pressing 'Enter'. The script mode allows the user to write and save a complete set of instructions as a program file. Hence, the reason correctly explains the assertion.

1Application based question

In Python programming, this mode refers to the mode where the user can instantly obtain the output, for the input given. The moment a statement or a command is typed in the Python command prompt and the 'Enter' key is pressed, the output will appear on the next line of the interactive screen.

Read the above paragraph to answer the following questions:

(a) Name the mode where get the instant output on the screen.

(b) Write down representation of the default Python prompt.

Show SolutionHide Solution↓

(a) Interactive Mode

(b) The default Python prompt is represented by >>> (three greater-than signs).

1Write short notes

Write short notes on Character Sets with reference to Python language.

Show SolutionHide Solution↓

Python is a computer language that enables the users to communicate with the computer system, using the set of valid characters that the language can recognise, similar to the alphabet of English language. It may be any letter, digit or any other symbol. The different character sets used in Python include Letters (A-Z and a-z), Digits (0-9), Arithmetical Operators (+, -, *, /, %), Logical Operators (and, or, not), Relational Operators (<, <=, >, >=, == and !=), Special Characters (space, backslash, underscore, parenthesis, etc.) and White Spaces (Blank space, Tab key, Enter key, Newline).

2Write short notes

Write short notes on Escape Sequences with reference to Python language.

Show SolutionHide Solution↓

Escape sequences are some non-graphic characters which are used as commands to direct the cursor while printing. These characters are frequently used in Python codes. An escape sequence character begins with a backslash (\) and it is followed by one or more characters. Some common escape sequences are \t (Horizontal tab), \ (Backslash), ' (Single quote), " (Double quote), \b (Backspace) and \n (New line feed).

3Write short notes

Write short notes on Literals with reference to Python language.

Show SolutionHide Solution↓

When we write a code, we may come across some quantities which remain fixed (i.e., do not change) throughout the execution of the program. Such quantities are termed as Literals or Constants. These constants include integer, string and boolean values. For example, 345, "Computer", True, etc. are some literals used in Python.

4Write short notes

Write short notes on Identifiers with reference to Python language.

Show SolutionHide Solution↓

An identifier is a component of a programming statement (token) defined with a name to identify a block (i.e., a set of indented statements). A function name, a class name or a variable name are also referred to as identifiers. For example, in the statement n = 25, n is a variable name which refers to a specific identifier. Since Python is case sensitive, Num and num are considered to be two different identifiers.

5Write short notes

Write short notes on Assignments with reference to Python language.

Show SolutionHide Solution↓

Assigning means to store values in variables using a token '=' which acts as an assignment operator. The operand to the left of '=' operator is the variable name and the operand to the right of '=' operator is the value to be stored. For example, n = 15 means that the numeric constant 15 is stored in the variable n.

6Write short notes

Write short notes on Keywords with reference to Python language.

Show SolutionHide Solution↓

Keywords are the reserved words which are preserved by the system and carry special meaning for the language translator (interpreter). These words cannot be used as variable names in the program. Some examples of Python keywords are False, class, else, return, None, continue, for, not, True, def, if, or, and, del, import, pass, break, elif, is, while, etc.

7Write short notes

Write short notes on Punctuators with reference to Python language.

Show SolutionHide Solution↓

Punctuators are the special signs used as special characters in Python to organise the structure as well as to put emphasis on the expressions of the sentences. For example, Comma (,), colon (:), semicolon (;), [ ], { }, ( ), # are some of the punctuators commonly used in Python coding.

8Write short notes

Write short notes on Python output statement.

Show SolutionHide Solution↓

In Python, the print() function is used to view the output of a program on a standard output device (i.e., monitor), when executed. The content within the round brackets of print() function may be a value, a variable, a message or the combination of message and variables. For example, print(25+15) will display 40 on the screen, and print("PYTHON") will display PYTHON on the screen.

1Answer the following questions

What is object-oriented programming? Name two object oriented programming languages.

Show SolutionHide Solution↓

Object-oriented programming (OOP) is an approach in which the emphasis is laid on data rather than functions. It allows the user to split the complete program into a number of segments called Objects. The data values of an object can only be used within the functions of the same object and are not directly accessible to other objects of the program. However, the objects can communicate with each other through functions. This encourages data security.

Two object-oriented programming languages are Java and C++.

2Answer the following questions

Name two different modes in Python that you can work on.

Show SolutionHide Solution↓

The two different modes in Python that we can work on are:

  1. Interactive Mode — In this mode, the user can instantly obtain the output for the input given at the Python command prompt (>>>).

  2. Script Mode — In this mode, the user can create a program file and save the complete set of instructions in it for later execution.

3Answer the following questions

What is meant by cross-platform language?

Show SolutionHide Solution↓

A cross-platform language refers to a programming language that is platform independent, which means a program developed using such a language can run on different operating systems. For example, if Python code has been developed in Windows then its library can also run on other platforms such as UNIX, LINUX, Macintosh, etc. Hence, Python is referred to as a cross-platform compatible language.

4Answer the following questions

Python is a case sensitive programming language. Comment.

Show SolutionHide Solution↓

Python is a case sensitive programming language, which means it differentiates between the uppercase and lowercase letters. In Python, the keywords are case sensitive and all the keywords (except True, False and None) are in lowercase and they must be written as it is. Python is also case sensitive when it deals with identifiers. For example, Num and num are considered to be two different identifiers in Python.

5Answer the following questions

What is meant by an interpreter? Name an interpreter based programming language.

Show SolutionHide Solution↓

An interpreter is a software that is used to convert a program written in a high-level language into its equivalent machine language. It accepts instructions and generates its machine codes line-by-line or statement-by-statement. The control does not move to the next line of statement until the previous one is corrected.

Python is an interpreter-based programming language.

6Answer the following questions

What are the advantages of Python as a programming language?

Show SolutionHide Solution↓

The advantages of Python as a programming language are as follows:

  1. It is known for its simplicity and readability that makes it an excellent choice for both beginners and experienced programmers.
  2. It is an interpreter-based language which allows easier debugging and code development.
  3. It is dynamically typed which means we do not need to declare the data types explicitly, making it flexible and reliable.
  4. It is known for platform independence which makes it portable across operating systems, allowing real-time code execution and testing.
  5. The syntax is quite concise that allows the developers to prototype applications quickly with less code.
  6. It supports both object-oriented and procedural programming, providing versatility in coding styles.
  7. It is used in IoT (Internet of Things) applications due to its simplicity and versatility.
  8. It provides extensive support libraries like NumPy for numerical calculations and Pandas for data analytics, making it suitable for scientific and data-related applications.
7Answer the following questions

Python is free and open source. What is meant by this statement?

Show SolutionHide Solution↓

The statement "Python is free and open source" means that Python can be freely downloaded and used without any cost. The users can freely distribute the copies of the software, read the source code, make changes in it and use it in new programs. Python is available for free download from the website https://www.python.org.

8Answer the following questions

How is Python useful for the following applications? Explain in brief.

(a) Game Development

(b) Artificial Intelligence

Show SolutionHide Solution↓

(a) Game Development — Like Java and C++, Python also has various modules that support the development of video and 3D games. For example, PySoy is a 3D game engine which enables the users to develop interactive games. Some popular games which have been built using Python are Disney's ToonTown Online, Vega Strike, etc.

(b) Artificial Intelligence — Artificial Intelligence is the technology that makes use of machines, like computer systems or robots, to think and learn like the human mind. This can be done by developing computer system and algorithms that are capable of learning from data, reasoning, understanding natural language, perceiving their environment and adapting to new situations. Python is widely used in Artificial Intelligence due to its simplicity, readability and the availability of extensive libraries.

Press ↓ to reveal a solution and move to the next question. Back to Solutions for Class 9 ICSE Exploring Robotics & Artificial Intelligence.