0% found this document useful (0 votes)
7 views3 pages

Python Basics: Variables, Data Types, and Functions

The document contains a series of exercises related to Python programming, including multiple-choice questions, fill-in-the-blanks, true or false statements, and short answer questions. Key topics covered include the definition of Python, the distinction between an interpreter and a computer, the concept of variables, the print() function, Python modes, keywords, and data types. It provides examples and rules for variable naming, as well as descriptions of various data types used in Python.
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
0% found this document useful (0 votes)
7 views3 pages

Python Basics: Variables, Data Types, and Functions

The document contains a series of exercises related to Python programming, including multiple-choice questions, fill-in-the-blanks, true or false statements, and short answer questions. Key topics covered include the definition of Python, the distinction between an interpreter and a computer, the concept of variables, the print() function, Python modes, keywords, and data types. It provides examples and rules for variable naming, as well as descriptions of various data types used in Python.
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

A.

Tick the correct option

1. Float

2. 12emp

3. Tab key

4. Print

5.50

B. Fill in the blanks

1. Python

2. Gudio van Rossum

3. Variable

4. Data type

5. newline(\n)

C. True or false

1. False

[Link]

3. True

4. True

5. False

D. Answer the following questions.

1. What is Python?

Python is a high-level programming language used to create programs.

It is easy to learn and understand because it uses simple English-like words.

Python is used to make games, websites, apps, and for data analysis.

2. Distinguish between an Interpreter and a Computer


Interpreter Computer

[Link] interpreter translates code line by line 1.A computer is an electronic machine

[Link] converts programming language into

machine language [Link] processes data and gives output

[Link] helps in finding errors easily 3. It follows instructions given by programs

3. What is a Variable? What are the rules for naming a variable?

A variable is a name given to store data in a program.

Example: age = 10

Rules for naming a variable:

1. It must start with a letter or underscore (_)

2. It should not start with a number

3. No spaces are allowed

4. Special symbols are not allowed except underscore

5. Keywords cannot be used as variable names

4. Describe print()

The print() function is used to display output on the screen.

Example:

print("Hello Python")

5. Explain the two modes of Python

Python works in two modes:


1. Interactive Mode

Code is written and executed line by line

Output is shown immediately

2. Script Mode

Code is written in a file and saved with .py

Program is run as a whole

6. What are Keywords?

Keywords are reserved words in Python that have special meaning.

They cannot be used as variable names.

Examples:

if, else, for, while, print, True, False

7. Describe different types of data types used in Python

Data types tell the type of data stored in a variable.

Data Type Description Example

int Stores whole numbers x = 10

float Stores decimal numbersy = 2.5

str Stores text name = "Rakhi"

bool Stores True or False isTall = True

list Stores multiple values [1, 2, 3]

tuple Stores fixed values (10, 20)

You might also like