100% found this document useful (1 vote)
48 views4 pages

Class 9 Python Reflection Worksheet

The document is a reflection worksheet for Class 9 on Artificial Intelligence, specifically focusing on Python programming. It includes multiple-choice questions, short answer questions, and coding exercises to assess understanding of Python concepts such as data types, operators, and functions. Additionally, it contains true or false statements and requests for definitions of key terms related to programming.

Uploaded by

sidhantpareek2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
48 views4 pages

Class 9 Python Reflection Worksheet

The document is a reflection worksheet for Class 9 on Artificial Intelligence, specifically focusing on Python programming. It includes multiple-choice questions, short answer questions, and coding exercises to assess understanding of Python concepts such as data types, operators, and functions. Additionally, it contains true or false statements and requests for definitions of key terms related to programming.

Uploaded by

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

Reflection Worksheet/ Class 9 / Artificial Intelligence/ Unit-5 Python

Multiple Choice Questions-

1 Who developed Python Programming Language?

a) Wick Van Rossum b) Rasmus Lerdorf c) Guido Van Rossum d) Niene Stom

2 In Python, which of the following characters is used to create single line comment?

a) // b) # c) ! d) /*

3 An identifier cannot start with a ________

a) Number b) Character c) Underscore d) None of the above

4 ______________ has a specific meaning in python program

a) Constant b) Variable c) Keyword d) Identifier

5 Write the output of the following python statement - print(10//3)

a) 3 b) 3.33 c) 1 d) 0

6 Which of the following is the valid Python file extension?

a) . python b) . pl c) . py d) . p

7 Numbers with fractions or decimal points are called ________ datatype.

a) Integer b) String c) Float d) None of the above

8 _______is an ordered sequence of letters/characters. They are enclosed in single quotes (‘ ’ ) or


double (“ ”).

a) String b) Integer c) Float d) None of the above

9 ___________ are a sequence of values of any type, and are indexed by integers. They are immutable
and enclosed in ().

a) String b) Lists c) Tuples d) All of the above

10 _________ function is used to display given output in python.

a) printf() b) print() c) scan() d) None of the above

11 _________ function is used to take input from the user in python.

a) input() b) insert() c) store() d) None of the above


12 The data type of 14.5 is __________

a) int b) float c) string d) list

13 ___________ operator gives the remainder in Python.

a) % b) / c) // d) *

14 __________ operator is used to find the square of a number

a) ^ b) * c) ** d) //

15 What does the following code print?

if 4 + 5 == 10:

print("TRUE")

else:

print("FALSE")

a) TRUE b) FALSE c) None of them d) TRUE FALSE

16 What will be the data type of following variable?

A= “100”

a) int b) float c) string d) list

17 The smallest element of python coding is called ______

a) Identifiers b) Tokens c) Keywords d) Delimeters

18 Find the invalid variable among the following:

a) 1st_place b) my_place c) _first d) Fun

19 T=[10,20,30,40] is a type of which datatype in python

a) int b) string c) list d) tuple

20 The _________ mode of python gives instant result of typed statement

a) Interactive mode b) Script mode

c) Combination of interactive and script mode d) All of these


2 mark Questions

1 What is the Difference between Interactive mode and script mode?

2 What are the basic datatypes in Python?

3 What is a variable?

4 What are the arithmetic operators in Python?

5 What are lists in python?

6 What will be out of the following?

for I in range(1,10,2):

print(I)

7 What does the following code print?

if 4 + 5 == 10:

print("TRUE")

else:

print("FALSE")

8.

L=[10, “New”, 34.5,30,40]

print( L[1])

L[2]=50

print(L)

9 What will be the output of the following?

print (“hello \n” )

print(“Class 9\n Artificial Intelligence”)

State True or False-

a) Python is case sensitive programming language

b) A variable’s value once assigned cannot be changed


Identify the datatype in the following

a) 15.3 b) “123” c) “CBSE” d) K=[1,2,3,4]

Write the output of the following-

A,B=10,20

A,B=B,A

print(A.B)

Rewrite the following by correcting the errors

Sname=int(input(“Enter Name”))

M=int(input(“Enter Mark”)

if M>33

print(“Pass”)

otherwise:

print(“Fail”)

Define the following terms

a) Identifiers b) Keywords c) Expression d) Tokens

Common questions

Powered by AI

Programmers face challenges with Python data types due to operations involving type compatibility, such as arithmetic on incompatible types or data-driven decision making where correct data type is crucial. Python facilitates effective datatype handling by providing dynamic typing and a wide range of built-in functions to convert between types (e.g., 'int()', 'float()', 'str()'). This dynamic nature allows for flexible and adaptive operations matching runtime requirements, but also demands careful type management to avoid errors in type operations .

Improper handling of identifiers in Python can lead to execution errors, such as name collisions or scope-related issues that complicate debugging and affect program accuracy. It can result in unintentional overwriting of values and obscure bugs that are hard to track down. Effective strategies to manage identifiers include adhering to consistent naming conventions, using descriptive names to convey the purpose and scope of variables, and leveraging namespaces to partition and organize code logically. Code reviews and static analysis tools can aid in evaluating identifier usage consistency .

The key differences between Interactive mode and Script mode in Python revolve around execution and debugging processes. Interactive mode allows immediate execution of individual statements and is suited for testing small code snippets, fostering an experimental approach. Script mode, however, is used to execute saved scripts that contain multiple lines of code, facilitating development of larger applications and allowing for structured testing and debugging procedures. These differences influence programmers by providing flexibility: Interactive mode is ideal for learning and prototyping, while Script mode supports project development and maintenance .

A programmer should use the integer division operator '//' over the standard division operator '/' when the intent is to obtain the quotient without any fractional component, that is, a whole number. This is particularly beneficial in scenarios where only the integer part of the division result is required, such as in iteration indices or when performing calculations that require compatibility with integer-only systems. The integer division operator provides a clear and efficient way to discard the remainder and enhance performance in algorithms where exact integer results are necessary .

The 'print()' function in Python is used to display output to the user, making it essential for communicating program results and diagnostics. The 'input()' function is used to acquire data from the user, facilitating interactive programs where user input is required for further processing. These functions are central to the user experience by enabling clear communication between the program and its users, contributing to user-friendly interfaces and interactive logic flows that depend on user intervention to perform tasks or make decisions .

Guido Van Rossum developed the Python programming language. The creation of Python significantly impacted computer programming by introducing a language that emphasizes readability and simplicity, making it widely accessible and adopted for both education and complex software development. Python's design philosophy prioritizes code readability, allowing programmers to write clear and logical code for small and large-scale projects .

Tuples in Python differ from lists in that they are immutable, meaning their elements cannot be changed once defined, while lists are mutable and can be modified. This immutability makes tuples suitable for storing fixed collections of items, especially when it is important to ensure data integrity. Lists are more flexible, allowing for dynamic modifications such as adding, removing, or changing elements, making them ideal for collections that require frequent changes. Depending on the needs of a project, these characteristics influence the choice between using tuples or lists .

Python is considered a case-sensitive programming language because it distinguishes between uppercase and lowercase letters in identifiers. This means that variables named 'Variable', 'variable', and 'VARIABLE' will be interpreted as distinct and separate entities. The implications of this feature for software developers include the necessity of maintaining consistent naming conventions to avoid errors and misunderstandings in code, and it necessitates a detailed and systematic approach when collaborating in large development teams to ensure that naming conventions are followed universally .

Using keywords in Python significantly affects program structure and readability as they define the language's syntax and structure. Keywords are reserved words with predefined meanings and functions, such as 'if', 'else', 'for', etc. Their use ensures that code follows a consistent structure, enabling programmers to easily understand the flow and functionality of the program. They prevent ambiguity and errors by clearly defining control flows and functions, making them crucial for maintaining code semantics across various parts of the program .

Using an incorrect file extension when saving Python scripts, such as '.pl' or '.p', rather than '.py', can lead to execution errors, misinterpretation by the Python interpreter, and confusion in file integration with development environments. This mistake could potentially disrupt the automated processes in IDEs and affect script portability. To systematically avoid this, best practices include establishing standardized naming conventions, integrating scripts into version control systems with checks for file extensions, and employing IDE features or scripts to verify file compliance before committing changes .

You might also like