1. What is Python?
Ans: Python is high-Level, interpreted, interactive and object oriented-scripting language. It was designed to be easily readable; uses English keywords frequently whereas other languages use punctuation. It has fewer syntactical constructions than other languages.
2. Discuss some characteristics of Python Language.
Ans: Python has following features:
Easy-to-Learn: Python has relatively few keywords, simple structure and a clearly defined syntax. So, it is easy to learn and use.
Easy-to-read: Python code is much more clearly defined and visible to the eyes. So, programs written in python are easily readable and understandable.
Interactive mode: It supports an interactive mode in which we can enter results from a terminal right to the program, allowing interactive testing and debugging of code.
Portable: Python can run on a wide variety of hardware platform and has the same interface on all platforms. so, it is called platform independent programming language.
3. What do you mean by the statement ‘python interactive’?
ANS: This
statement means that we can actually work at a python prompt and interact with
the interpreter directly to execute our programs and get the output.
4. Is python case-sensitive?
ANS: Yes, python
is a case-sensitive programming language. Thus AGE, Age and age are three
different identifier in python. Some legal identifier are x, age, marks2, total_marks,
etc.
5. What are comments in a python program?
ANS: In programming, comment is the text that we insert into the program for documentation purpose. A hash sign (#) that is not inside a string literal begins a comment. All character after the sign # and up to the end of the physical line (a physical line is what we see as a line when we write a program) are part of the comment, and the python interpreter ignores them.
6. What is multi-line statement?
ANS: Statements
in python typically end with a new line, i.e. at the end of the line. Python
does however, allow the line to continue by using the line continuation
character (\) at the end of the line. Such a statement is called multi-line
statement.
7. Why is indentation important in python?
ANS: Python
programmers almost always use four space for the first level of indentation, eight
space for the next level (a code block nested inside another code block), and
so on. The indentation must be the same for every line of a block. We get an
indentation error message (syntax error) if we use, for example, four spaces on
one line of a block and three spaces on another line in the same block.
8. Why is Python called interpreted Language?
Ans: A program
written in a compiled language, Like C or C++, is converted from the source
language, i.e., C or C++ into language that is understood by our computer
(binary code, i.e., 0s and 1s) using a compiler with various flags and option.
When we run the program, the linker/ loader software copies the program from
hard disk memory and starts executing. Python, on the other hand, does not need
to be converted into binary. We just run the program directly from the source
code. Internally, Python convert the source code into an intermediate from
called byte codes and then translate this into the native language of our
computer and then runs it. All this, actually makes using Python much easier
since we don’t have to worry about compiling the program, making sure that the
proper libraries are linked and loaded, etc. This also makes our programs much
more portable.
9. Python is free and open sources.
ANS: Python is an
example of floss (free/libre and open source software). In simple terms, we can
freely distribute copies of this software, read its source code, make changes
to it, and use pieces of in new free programs. floss is based on the concept of
a community which shares knowledge. This is one of the reasons why python is
good-it has been created and constantly improved and upgraded by a community to
make it better.
10. Why is python considered an ideal language for scripting application development?
ANS: Python is an
easy to learn, powerful programming language. it has efficient high-level data
structures and a simple but effective approach to object-oriented programming.
Python’s elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in
many areas on most platforms.
11.’Python is a true cross-platform language’.
ANS: Python can
run equally well on a variety of platform such as Windows, Linux/phones. So, it
is a portable and true cross-platform language.
12. The only prompt used by the python interactive system is the one consisting of three right angle brackets (>>>). is it true or false?
ANS: False. Python
interactive system also uses a secondary prompt consisting of three periods (…).
13. Write one advantage of using triple quoted string.
ANS: The use of
triple quoted strings makes it possible for us to continue a string on a new line,
and the preserve the line break in the string.
14. What is a script?
ANS: A script is
a text file containing python program.
15. Indentation in python is used for cosmetic purpose only. is it true or false?
ANS: False.
Indentation is used in python to determine the grouping of statements, which is
critical to the success of a program.
0 Comments