Curriculum
Course: Grade XI Computer Science
Login
Text lesson

Le-5 Getting Started with Python

School Revise · Class 11 Computer Science · Chapter 5

Getting Started with Python

Code 083, Class 11. Python is simple and readable. Here we run our first programs, print output, store values in variables and meet the basic data types.

4

Core data types

2

Ways to run Python

What this chapter is about

Python lets us instruct the computer in plain, readable words. In this chapter we run Python two ways, print messages, store values in variables, and learn the common data types.

1. Two ways to run Python

In interactive mode you type one line and see the result at once. In script mode you save many lines in a file and run them together, which is how real programs are written.

2. print, variables and comments

The print() function shows output. A variable stores a value, written as name = value. A line beginning with # is a comment, a note for humans that Python ignores.

Example: city = “Doha” then print(“I live in”, city) displays: I live in Doha

3. Data types and input

Common data types are int (whole numbers), float (decimals), str (text) and bool (True or False). Python picks the type from the value. The input() function reads text typed by the user.

Practise with the interactive

Build tiny programs by tapping and watch Python read each line. The interactive opens right here in the lesson.

Try it in the code lab

Write and run real Python right here in the lesson, then work through the practice problems with answers.

Starting Python...

Coding practice problems, with answers

Type each one into the code lab above, then open the card to see the worked solution and its output.

Problem 1. Print a welcome message.

SOLUTION

print(“Welcome to School Revise”)

OUTPUT

Welcome to School Revise
Problem 2. Store two numbers and print their sum.

SOLUTION

a = 5 b = 3 print(a + b)

OUTPUT

8
Problem 3. Ask the user their name and greet them.

SOLUTION

name = input(“Your name: “) print(“Hello,”, name)

OUTPUT

Your name: Ravi Hello, Ravi
Problem 4. Print the area of a rectangle with length 8 and breadth 5.

SOLUTION

l = 8 b = 5 print(“Area =”, l * b)

OUTPUT

Area = 40
Problem 5. Swap two variables and print them.

SOLUTION

a, b = 5, 9 a, b = b, a print(a, b)

OUTPUT

9 5
Problem 6. Print the data type of the value 3.14.

SOLUTION

print(type(3.14))

OUTPUT

<class ‘float’>
Problem 7. Convert 20 degrees Celsius to Fahrenheit.

SOLUTION

c = 20 f = c * 9 / 5 + 32 print(f)

OUTPUT

68.0
Problem 8. Print the average of the marks 82, 91 and 76.

SOLUTION

print((82 + 91 + 76) / 3)

OUTPUT

83.0
Problem 9. Store your school name and print it with its type.

SOLUTION

s = “Python” print(s, type(s))

OUTPUT

Python <class ‘str’>
Problem 10. Read two numbers from the user and print their product.

SOLUTION

x = int(input(“x: “)) y = int(input(“y: “)) print(“Product =”, x * y)

OUTPUT

x: 4 y: 6 Product = 24

Practice set A, multiple choice

1. Which function shows output on the screen?

print(). For example print(“Hi”) shows Hi.

2. What is the data type of 3.14?

float, because it has a decimal point.

3. A line starting with # is a …

comment, which Python ignores.

4. Which function reads text typed by the user?

input().

Quick summary

Python runs in interactive mode (line by line) or script mode (a saved file). print() shows output, a variable stores a value with name = value, and # marks a comment. Common data types are int, float, str and bool, and input() reads text from the user.

Open the Virtual Lab

These free Class 11 Computer Science notes explain getting started with Python, interactive and script mode, print, variables, comments, data types and input with worked Python programs and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.

© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 11 Computer Science syllabus. Unauthorised copying is not permitted.

Layer 1
Login Categories