91% found this document useful (11 votes)
25K views

Class-7 Python Notes

Uploaded by

Anusua Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
91% found this document useful (11 votes)
25K views

Class-7 Python Notes

Uploaded by

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

Lesson-9

PYTHON LANGUAGE
1. What is Python?
Ans: Python is a high-level programming language. It has simple language syntax which
makes it easy to read and write. It was developed by Guido Van Rossum in 1991. Python
is used in various application areas such as:
• Web application
• Scientific & Numeric computational applications
• Games
• Images Processing and graphic designing applications
• Network programming
• Artificial Intelligence
• Machine Learning

2. What are the features of Python Language.


Ans: Some important features of python are-
• Easy to code
• Open-source language
• Object Oriented
• Integrated & Extensible language
• Interpreted language
• Dynamically typed language

3. Define Variables.
Ans: Variables are memory locations for storing data values. When a variable is created,
some space is allocated in memory for it. To create a variable in python you just need to
assign a value to a variable. For Ex-
age = 30, name = “amit”

4. What are the rules for naming variables?


Ans: The rules for naming variables are –
• A variable name must start with a letter (a-z, A-Z) or an underscore ( _ ).
• A variable name cannot start with a number.
• A variable name can only contain alpha-numeric characters and underscore
(A-Z, a-z, 0-9 and _ )
• Variable names are case sensitive (For example - age, Age, AGE are three
different variables)
• Keyword cannot be used as variable names.

5. What do you mean be Python keywords?


Ans: Keywords are the reserved words in Python. We cannot use a keyword as a
variable names as they carry a special meaning for the interpreter. Keywords are case
sensitive. There are 33 keywords in python. For Ex- True, if, else, for, in, return, pass etc.

6. What are Data Types?


Ans: The type of data or value that can be stored in variables are called data type.
The basic data types in python are integer, float and string.
7. Define Comments in Python?
Ans: Comments are the text written in program for better understanding of the code. A
comment in python starts with the hash (#) character. Comments are not a part of the
code and are ignored by the Python interpreter.
For Ex- #Program for adding two numbers

8. What is the use of print () function.


Ans: The print() function is used to print the message or value of the variable on the
screen. The syntax of print() function is –
print(“message”, variable_name)
Example –
1) To print a message like “ Welcome to Python” on the screen
print(“Welcome to python”)
2) To print value of a variable like a = 5
print(“The value of a is-“, a)

9. What is the use of input () function.


Ans: The input() function is used to take input from the user during the execution of the
program. By default it takes the input in the form of string. The syntax of input ()
function is –
input(prompt), here prompt is a message for the user related to the code.
Example-
x = input (“ What is your name?”)
In this example the input function will display “ What is your name” on the
screen to get the input from the user and store/assign it to in the variable x.
Note: By default input() function takes the input in the form of string. So, to take the
numeric value as input, you need to convert it into integer.
Example-
x = int(input(“What is your age?”)

You might also like