0% found this document useful (0 votes)
131 views2 pages

Introduction to Python for Class 9

Source Code IT class 6th Ch-9 Exercise

Uploaded by

Harmandeep Kaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views2 pages

Introduction to Python for Class 9

Source Code IT class 6th Ch-9 Exercise

Uploaded by

Harmandeep Kaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter- 9.

Python - Introduction
EXERCISE:

A. Tick [] the correct answer.

1. a 3. b

2. b 4. c

B. Write 'T' for True and 'F' for False statements.

1. T 3. F 5. T

2. F 4. T 6. T

C. Fill in the blanks.

1. F5 [Link] 5. statement

2. Keywords 4. Indentation

D. Define The following.

1. Token: A token is a smallest element of a program that is meaningful to the


interpreter. Tokens supported in Python include identifiers, delimiter, keywords, literals
and operators among others.

2. Operator: Operator is a special symbol that carries out arithmetic and logical
computations. There are many types of operators in Python like Arithmetic, Relational,
Logical, Assignments, etc.

3. Comments: They are used to explain Python code and make it more readable. Python
interpreter ignores the text written in the comment.

E. Differentiate between the following.

Keywords are the reserved words in Python and cannot be used as constant, variable or
any other identifier names. There are 33 keywords in Python 3.

Literals are the data items that never change their value throughout the program run are
called literals. Theoretically, literal means any number, text or other any information that
represents a value.
F. Answer in 1-2 sentences.

1. Python was founded by Guido Van Rossum in early 1990's.

2. A random name made out of letters, digits and/or underscore () to identify a function
name, a program name or a memory location (variable or constant) is known as
identifier.

3. Variables are used to store data in the memory. The data can be numbers, text and/or
objects.

4. A Python program is made up of one or more physical lines. Each physical line may
end with a comment.

An indentation is an empty space at the beginning of block of code. Python uses


indentation to express the block structure of a program.

G. Answer briefly.

1. Data type is used to define the type of value a data can contain. The data types in

Python are:

a. Integer: Integers are the whole numbers consisting of + or sign without decimal point
such as 1000, -88, etc.

b. Float: Float data type represents floating point numbers which contain decimal point.
For example, 0.5, -4.567, 0.001, etc.

c. String: It is a sequence of characters (alphabets, numbers, operators and punctuation)


used to store and represent text- based information. Single quotes ('') and double
quotes ("") are used to represent strings in Python.

2. Input() and print() are used for standard input and output operations in Python. Input()
is used to get input from user. This function helps user to input the values and text for
the operation. Input() function always returns string value.

Print() is used to print the value of given input value or string. It helps to show output on
screen.

H. Application based-Question.

She can do so by using int function.

Common questions

Powered by AI

Python's syntax uses keywords to define control flow mechanisms and operations essential for program logic, such as loops and conditionals, ensuring consistent interpretations of these constructs . Meanwhile, literals represent constant, immutable values that are employed within these constructs, keeping data stable and consistent . Together, they provide a framework of stability that underpins the program's operational functionality.

The input() function in Python allows programs to receive inputs from users, commonly used to provide interactive inputs for operations or data processing . Conversely, the print() function displays output, which can be the result of computations or user-provided data, onto the screen . Together, these functions facilitate an interactive experience between the user and the Python program.

Data types in Python are essential as they define the nature and operations of data that can be handled by the program. Python supports data types such as integers, floats, and strings, enabling the program to store and manipulate numeric and textual information appropriately . The choice of data type determines how operations are performed, memory use, and precision of computations which are critical for effective programming.

Indentation in Python is crucial as it defines the block structure of the code, determining how blocks of code are grouped together. Python uses indentation to signify code hierarchy and nesting instead of curly braces used by many other languages . Improper indentation can lead to syntax errors or unexpected code behavior, hence it is essential for correctness and readability.

Operators are special symbols in Python that perform arithmetic and logical operations, and they are instrumental in manipulating data values and variables. They include various types like arithmetic, relational, logical, and assignments . Unlike other tokens that may identify variables or represent constants, operators define the fundamental logic processing capabilities within a program.

Literals in Python represent fixed data values whose value does not change during program execution, such as numbers or strings . Identifiers, however, are names created by the programmer to represent variables, functions, or other entities within the code; they can change or be altered during execution . Thus, literals convey static information while identifiers enable dynamic interactions and referencing within a program.

Guido Van Rossum's decision to use indentation as a means of defining block structures in Python impacts readability and simplicity in modern Python programming by eliminating the need for brackets to delineate code blocks. This initially controversial design choice highlights Python's emphasis on readable and maintainable code structure . The use of indentation aids error prevention and enforces a uniform coding style.

Comments in Python are used to explain code and improve readability; they are ignored by the Python interpreter and do not affect program execution . Keywords, on the other hand, are reserved words that have a special meaning in Python's language syntax and cannot be used for variable identification or naming. Keywords control the core functionalities of the Python program .

Tokens are the smallest elements of a program that are meaningful to the interpreter; they include identifiers, delimiters, keywords, literals, operators, and others . Literals, a type of token, represent constant data values that do not change during the program's execution, such as numbers and strings . While tokens are diverse program elements, literals specifically denote fixed values.

Python identifiers must be composed of letters, digits, or underscores, beginning with a letter or an underscore, ensuring that variables and functions are defined deliberately and semantically . By following these rules, identifiers maintain clarity and avoid conflicts with reserved keywords, contributing to robust and error-resilient programming practices.

You might also like