0% found this document useful (0 votes)
10 views7 pages

? Chapter 5 Getting Started With Python

Uploaded by

ffstellartsr0219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views7 pages

? Chapter 5 Getting Started With Python

Uploaded by

ffstellartsr0219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter: Getting Started with Python (Class 11 –

Sumita Arora)

1. Introduction to Python

• Python is a high-level, interpreted, interactive, and object-oriented scripting


language.
• Created by Guido van Rossum in the late 1980s.
• Python emphasizes readability and ease of use.

Key Features:

• Easy to learn and use


• Interpreted and interactive
• Open source
• High-level language
• Portable
• Dynamically typed

2. Python Installation & IDEs

• Popular IDEs: IDLE, PyCharm, Jupyter Notebook, VS Code


• Python prompt: >>> (used for interactive mode)
• File extension: .py

3. Python as a Calculator

• Supports operations: +, -, *, /, //, %, **


• Example:
• >>> 5 + 3 # 8
• >>> 10 // 3 # 3 (Floor division)
• >>> 2 ** 3 # 8 (Exponentiation)

4. Python Identifiers and Keywords

• Identifiers: Names for variables, functions, etc.


• Rules:
o Can’t start with a digit
o No special characters except _
o Case-sensitive
• Keywords: Reserved words like if, else, True, None, and, or, etc.

5. Variables and Data Types

• Variables store values using the assignment operator =.


• Dynamic typing: No need to declare the type.

Data Types:

Type Example
Integer 10, -5
Float 3.14, 2.0
String 'hello', "hi"
Boolean True, False
NoneType None

6. Input and Output

• input() – Takes user input as a string.


• print() – Displays output.

name = input("Enter your name: ")


print("Hello", name)

7. Errors in Python

• Syntax Error: Incorrect code formatting.


• Runtime Error: Occurs during execution (e.g., division by zero).
• Logical Error: Code runs but gives incorrect output.

Important Questions (Board + Viva + Practice)

Short Answer Type:

1. What is Python? List any four features.


2. Differentiate between compiler and interpreter.
3. Name any five Python IDEs.
4. What is the difference between = and == in Python?
5. Explain the use of input() function.

Long Answer Type:


1. Explain any five data types in Python with examples.
2. How is Python different from other programming languages like C or Java?
3. Write a Python program to:
o Accept two numbers and display their sum, product, and average.
o Accept the radius and print the area of the circle.

Output-based Questions:

1. Predict the output:


2. x = 5
3. y = 2
4. print(x // y)
5. print(x ** y)
6. Find the error:
7. 5num = 10
8. print("Value is" + 5num)

Viva Questions:

• Who developed Python?


• What is a variable in Python?
• What is the difference between print() and input()?
• Name any two data types in Python.
• What will be the output of print(3 + 4.5)?

SOLUTIONS – IMPORTANT QUESTIONS

Short Answer Type Questions

1. What is Python? List any four features.


Answer:
Python is a high-level, interpreted programming language developed by Guido van Rossum in the
late 1980s.
Features:

• Easy to learn and use

• Interpreted language

• Portable and platform-independent

• Supports object-oriented programming

2. Differentiate between compiler and interpreter.


Answer:
Compiler Interpreter

Translates the entire program at once Translates one line at a time

Faster in execution once compiled Slower than compiled programs

Examples: C, C++ Example: Python

Shows all errors at once Shows one error at a time

3. Name any five Python IDEs.


Answer:

1. IDLE

2. PyCharm

3. Jupyter Notebook

4. Visual Studio Code (VS Code)

5. Thonny

4. What is the difference between = and == in Python?


Answer:

• = is the assignment operator. It assigns a value to a variable.


Example: x = 5

• == is the comparison operator. It checks whether two values are equal.


Example: x == 5 returns True if x is 5.

5. Explain the use of input() function.


Answer:
input() is used to accept user input from the keyboard. It always returns a string.

Example:

name = input("Enter your name: ")

print("Hello", name)

Long Answer Type Questions

1. Explain any five data types in Python with examples.


Answer:
Data Type Description Example

Integer Whole numbers x = 10

Float Decimal numbers y = 3.14

String Sequence of characters name = "Tarun"

Boolean True or False values is_valid = True

NoneType Represents no value x = None

2. How is Python different from other programming languages like C or Java?


Answer:

Feature Python C/Java

Syntax Simple and readable Complex syntax

Typing Dynamically typed Statically typed

Compilation Interpreted Compiled

Code Length Shorter code Longer code

Memory Mgmt. Automatic Manual (Java partial)

3. Write a Python program to:


a. Accept two numbers and display their sum, product, and average.

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

sum_ = num1 + num2

product = num1 * num2

average = (num1 + num2) / 2

print("Sum:", sum_)

print("Product:", product)

print("Average:", average)

b. Accept the radius and print the area of the circle.


radius = float(input("Enter the radius: "))

area = 3.1416 * radius ** 2

print("Area of the circle:", area)

Output-based Questions

1. Predict the output:

x=5

y=2

print(x // y) # Floor Division → 2

print(x ** y) # Exponentiation → 25

Output:

25

2. Find the error:

5num = 10 # Invalid variable name (starts with a digit)

print("Value is" + 5num) # Cannot concatenate string and integer

Corrected Code:

num5 = 10

print("Value is " + str(num5))

Viva Questions with Answers

Question Answer

Who developed Python? Guido van Rossum

What is a variable in Python? A container to store a value

What is the difference between print() and input()? print() displays output, input() takes user input

Name any two data types in Python. Integer, String


Question Answer

What will be the output of print(3 + 4.5)? 7.5 (Integer + Float = Float)

You might also like