0% found this document useful (0 votes)
14 views

Introduction To Python9876543210

The document contains 10 short answer questions and 10 long answer questions about Python programming concepts. The questions cover topics like Python lists, if/else statements, the print() and input() functions, type conversion, variables, operators, and while loops.

Uploaded by

saliksayeed09
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Introduction To Python9876543210

The document contains 10 short answer questions and 10 long answer questions about Python programming concepts. The questions cover topics like Python lists, if/else statements, the print() and input() functions, type conversion, variables, operators, and while loops.

Uploaded by

saliksayeed09
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Unit-4

Introduction to Python

Short Answer type questions:

Q 1: What are the different properties of lists?


Ans:The important characteristics of Python lists are as follows:
(i) Lists are ordered.
(ii) Lists can contain any arbitrary objects.
(iii) List elements can be accessed by index.
(iv) Lists can be nested to arbitrary depth.
(v) Lists are mutable.
(vi) Lists are dynamic.

Q 2: What is the difference between an “if” and and “if-else” statement?


Ans: In if, the statements inside the if block will execute, if the condition is true and the control
is passed to the next statement after the if block. In the if else, if the condition is true, the
statements inside the if block will execute and if the condition is false the statements in the if
else block will execute.

Q 3: What is IDLE?
Ans: IDLE (Integrated Development and Learning Environment) is an integrated development
environment (IDE) for Python. The Python installer for Windows contains the IDLE module
by default.IDLE is not available by default in Python distributions for Linux.

IDLE can be used to execute a single statement just like Python Shell and also to create,
modify, and execute Python scripts. IDLE provides a fully-featured text editor to create
Python script that includes features like syntax highlighting, autocompletion, and smart
indent. It also has a debugger with stepping and breakpoints features.

Q 4: Who developed python?


Ans: Python is one of the most popular programming languages used for designing Artificial
Systems. This language was created by Guido van Rossum and released in 1991. (pg-280)

Q 5: What is the difference between a Keyword and an identifier?


Ans: A Python keyword is a reserved word that cannot be used to name a variable, class,
functions, or anything else. These keywords serve a special purpose in the Python
programming language and should only be used in manner intended.

Identifiers in Python are words that we use to specify or declare variables. An identifier is
any word that we employ as a variable name. It is vital to remember that the identifiers are
case sensitive. (pg-286)

Q 6: Write the use of print() function.


Ans: The python print() function is a built-in function that allows you to display text or
variables on the screen. It is used to output information to the console or standard output.
You can use the print() function to display messages, variables, and even the results of
calculations. (pg-292)
Q 7: Define the input() function.
Ans: The input() takes the input from the user. The user must enter the input when the
prompt message pops on the screen with the help of the keyboard. Once the input is given,
this is evaluated and returned as a string. (pg-294)
Q 8: What is type conversion?
Ans: The process of converting one Python data type(integer,string,float,etc) into another
data type is known as type conversion. There are mainly two types of type conversion
methods in Python: implicit type conversion and explicit type conversion. (pg-296)

Q 9: List the type of type conversion.


Ans: There are two types of Type Conversion in Python:
(i) Python Implicit Type Conversion: In Implicit type conversion of data types in Python, the
Python interpreter automatically converts one data type to another without any user
involvement.
(ii) Python Explicit Type Conversion: In Explicit Type Conversion in Python, the data type is
manually changed by the user as per their requirement.

Q 10: What is explicit type conversion?


Ans: In explicit type conversion, the users themselves convert the data type of an object to
another data type, which they require. Predefined functions, like int(), float(), str() etc., are
used to perform the explicit type conversion. (pg-296)

Long Answer type questions:

Q 1: What are the pros and cons of python?


Ans: The pros of Python:
(i) Python is easy to learn and read
(ii) Python enhances productivity
(iii) Python has a vast collection of libraries
(iv) Python is free, open-source, and has a vibrant community
(v) Python is a portable programming language
(vi) Python is an interpreted language
The cons of python programming language:
(i) Python has speed limitations
(ii)Python is not so strong with mobile computing
(iii) Python can have runtime errors
(iv) Python consumes a lot of memory space
(v) Python is not easy to test

Q 2: What are the difference between an algorithm and a flowchart?


Ans: An algorithm is a step-by-step method for solving a problem. A procedure is finite
sequence of instructions that must be completed in a specific amount of time. Every problem
can be addressed using an algorithm.

A flowchart is a visual representation of your computer program as the pseudocode is


written representation.Both flowchart and the pseudocode are similar in sense that both use
natural language and there is no need for syntax. (pg-268 & 270)

Q 3: What are the benefits of using Python for AI?


Ans: (i) Python is the simplest of all programming language.
(ii)Python includes in-built libraries such as Numpy for scientific calculations, Scipy for
sophisticated computing, and pybrain for machine learning (Python machine learning),
making it one of the top language for AI.
(iii) Python developers all over the world provide considerable support and guidance through
tutorials and forums, making it much easier to help the Coder than with another popular
language.
(iv) Python is platform-independent, making it one of the most versatile and well-known
solution for numerous platform and technologies, with only minor changes to the
fundamentals of coding.
(v) Python offers the most versatility of any applications, having the choice of using an OOPs
technique or scripting. You can also utilise the IDE to search for all codes and help developer
who are suffering with different algorithms. (pg- 281)

Q 4: Mention some applications of Python.


Ans: The Python language is one of the favourite of the AI programmers because:
(i) It can work on different operating systems and platforms like, Windows, Mac OS, Linux,
Raspberry Pi, etc.
(ii) It has simple English-like Syntax.
(iii) It runs on the interpreter System, i.e, the code written in Python can be executed as
soon as it is written.
(iv) It can create workflows
(v) It can interact with database.
(vi) it is capable of handling big data.
(vii) It can be used for performing Complex mathematical operations. (pg-281)

Q 5: What is the difference between a statement and an expression in Python?


Ans: Any line of code that you write in a program is called a statement. A set of statement
help the user to get the required output. Statements and expressions are slightly different.
Statements are units of code which the interpreter can execute. Expression, on the other
hand, are a combination of values, variables, functions, and/or operators that the interpreter
evaluates before execution.

Q 6: What is the difference between operators and operands?


Ans: Operators are special characters that represent computation. They are used on
operands, which can be either values are variables. The same operators can behave
differently depending on the data type. When operators are applied to operands ,they
generate an expression. Arithmetic, Relational, Logical and Assignment operator are the four
types of operators. When value and variables are used with an operator, they are referred to
as operands. (pg- 290)

Q 7: Mention the rules for naming variables in Python.


Ans: (i) A variable name must start with a letter or the underscore character.
(ii) A variable name cannot start with a number.
(iii) A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9,
and _)
(iv) Variable names are case-sensitive (age, Age and AGE are three different variables)
(pg-288
Q 8: Describe the advantages and disadvantages of Python programming language.
Ans: Some of the main benefits of Python include its ease of use, concise and straightforward
syntax, and vast libraries. Other Python advantages are its portability, versatility, large user
base, and free & open source license. Some of the disadvantages of Python include its slow
speed and heavy memory usage.

Q 9: Create a Python list containing elements ‘I’, ‘am’, ‘the’, ‘best’ but print only the last
two elements.
Ans: List1=[‘I’,’am’,’the’,’best’]
Last_two_element=List1[-2:] #Slice the last two elements
Print( Last_two_element)

Output: [ ‘the’, ‘best’]

Q 10: Explain the functioning of the while loop in Python programming with the help of a
flowchart.
Ans: Python While Loop is used to execute a block of statements repeatedly until a given
condition is satisfied. And when the condition becomes false, the line immediately after
the loop in the program is executed.
Syntax:
while condition:
statements(code)

(pg-300)

You might also like