Python - Introduction to Python Question & Answer



Qus. When was Python released?

Ans- Python was released in February 1991.

Qus. Who developed Python?

Ans- Python was developed by Guido Van Rossum.

Qus. Which two languages contributed to Python as a Programming Language?

Ans- ABC language and Modula 3.

Qus. Is Python an Object Oriented Language?

Ans- Yes, Python is an object oriented language.

Qus. Python got its name from which show?

Ans- Python got its name from famous BBC comedy show “Monty Python’s Flying Circus”.

Qus. "Python is an interpreted language". What does it mean to you?

Ans- It means that the Python installation interprets and executes the code line by line at a time.

Qus. What does a cross platform language mean?

Ans- it means a language can run equally on variety of platforms-Windows, Linux/UNIX, Macintosh, Supercomputers, Smart phones etc.

Qus. Python is a Free and Open Source language. What do you understand by this feature?

Ans- It means Python is freely available without any cost. Its source code is also available. One can modify, improve/extend an open source software.

Qus. In how many ways, can you work in Python?

Ans-In two ways we can work in Python-

(i) Interactive mode

(ii) Script Mode

Qus. What is the difference between Interactive mode and Script Mode in Python?

Ans- In interactive mode, one command can run at a time and commands are not saved. Whereas in Script mode, we can save all the commands in the form of a program file and can see output of all lines together.

Qus. What are the advantages of Python?

Ans- Advantages-

i. Easy to use OO Language.

ii. Expressive Language.

iii. Interpreted Language.

iv. It is complete.

v. Cross-Platform Language.

vi. Free and Open Source.

vii. Variety of Usage/ Applications

Qus. What are the limitations of Python?

Ans- limitations-

i. Not the fastest language.

ii. Lesser Libraries than C, Java, Perl.

iii. Not strong on Type Binding.

iv. Not easily convertible.

Qus. Which of the following are not valid strings in Python?

(a)‖Hello‖ (b) ‗Hello‘ (c)‖Hello‘ (d) ‗Hello‖ (e) {Hello}

Ans- String (c) , (d) and (e ) are not valid strings.

Qus. Write Instructions in python to get the following result: (Do it in both interactive mode and script mode)

I am a student of KV Barabanki

I live in Barabanki

And I love Barabanki.

Barabanki is 20 KM away from Lucknow

This Place is famous for Dewa Sharif

Ans- In Interactive Mode-

>>> print("I am a student of KV Barabanki \nI live in Barabanki \nAnd I love Barabanki\n\n Barabanki is 20 KM away from Lucknow\n This Place is famous for Dewa Sharif")

In Script Mode-

print("I am a student of KV Barabanki \n I live in Barabanki \nAnd I love Barabanki\n\n Barabanki is 20 KM away from Lucknow\n This Place is famous for Dewa Sharif")

(save this code to a file and then run the file)

Qus. What is None literal in Python?

Ans: Python has one special literal, which is None. The None literal is used to indicate absence of value. It is also used to indicate the end of lists in Python. It means ―There is nothing here‖.

Qus. What is the difference between a keyword and an identifier?

Ans: Difference between Keyword and Identifier: Every language has keywords and identifiers, which are only understood by its compiler. Keywords are predefined reserved words, which possess special meaning. An identifier is a unique name given to a particular variable, function or label of class in the program.

Qus. What are literals in Python? How many types of Literals allowed in Python?

Ans: Literals: Python comes with some built-in objects. Some are used so often that Python has a quick way to make these objects, called literals.

The literals include the string, Unicode string, integer, float, long, list, tuple and dictionary types.

Qus. How many types of sequences are supported in Python?

Ans: Three Types of Sequences are supported in python:

(i) String

(ii) List

(iii) Tuple

Qus. What factors guide the choice of identifiers in program?

Ans:

(i) An identifier must start with a letter or underscore followed by any number of digits and/or letters.

(ii) No reserved word or standard identifier should be used.

(iii) No special character (Other than underscore) should be included in the identifier.

Qus. What is the difference between an expression and a statement in Python?

Ans: A statement is an instruction that the Python interpreter can execute. We have only seen the assignment statement so far. Some other kinds of statements that we‘ll see shortly are while statements, forstatements, if statements, and import statements. (There are other kinds too!) An expression is a combination of values, variables, operators, and calls to functions. Expressions need to be evaluated. If you ask Python to print an expression, the interpreter evaluates the expression and displays the result.

Qus. What are tokens in Python? How many types of tokens allowed in Python?

Ans: Tokens are the smallest unit of the program. There are following tokens in Python:

  •  Reserved words or Keywords
  •  Identifiers
  •  Literals Definition of all tokens may come. Which is not given
  •  Operators in this question bank.
  •  Punctuators

Qus. What are data types? What are Python‟s built-in core data types?

Ans. Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes. There are various data types in Python. Some of the important types are listed below.

(i) Numbers (ii) String (iii) List (iv) Tuple (v) Dictionary

Qus. Which data types of Python handle Numbers?

Ans. It is cleared by name that Number data types are used to store numeric value in Python. The Numbers in Python have following core data types:

(i) Integers

a. Integers (signed)

b. Booleans

(ii) Floating-Point Numbers

(iii) Complex Numbers


Qus. Why is Boolean considered a subtype of Integers?

Ans: Because Boolean Values False and True behave like the values 0 and 1, respectively. So Boolean type is a subtype of plain integers.


Qus. What do you understand by term "immutable"?

Ans: Immutable types are those data types that can never change their value in place. In Python the following types are immutable:

(i) integers

(ii) floating-point numbers

(iii) Booleans

(iv) Strings

(v) Tuples


Qus. What are mutable and immutable types in Python? List both of them.

Ans. Mutable types means those data types whose values can be changed at the time of execution.

They are as follows:

  • Lists
  • Dictionaries
  • Sets

Immutable types are those data types that can never change their value in place. In Python the following types are immutable:

  • integers
  • floating-point numbers
  • Booleans
  • Strings
  • Tuples


CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad