[go: up one dir, main page]

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

Class 6 Ls 8 Notes

Uploaded by

arjunkumar176e
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)
32 views3 pages

Class 6 Ls 8 Notes

Uploaded by

arjunkumar176e
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
You are on page 1/ 3

Ls-8: Introduction to Python

Programs

PROGRAM-1
1. Write a program to find the product of two numbers x and y where x=150 and y=200

X=150
Y=200
Product = x*y
print (‘The product of two numbers is ‘,Product)

PROGRAM-2
2. It takes 3hours to drive a distance of 192km on a motor way, create a program to
calculate the average speed in km/h?

Time= 3
Dist=192
Speed = Dist / Time
print (‘Average speed is ‘, Speed , ‘km/h’)

PROGRAM-3
3. To calculate and print the circumference and area of a circle
# Circumference of circle is 2 π r

Radius = 25
Circumference = 2 * (22/7) * Radius
print (‘The circumference of circle is ‘ , Circumference)

PROGRAM-4
4. To input the roll number, name and marks in five subjects of a subject. Calculate the
total and percentage marks of the student.

rollno=101
name= 'John'
M1=80
M2=87
M3=83
M4=78
M5=76
Total=M1+M2+M3+M4+M5
percentage=Total / 5
print('percentage is =', percentage)
Class-6
Ls-8: INTRODUCING PYTHON
1. Write any four features of python programming language
Ans. Python is a high-level programming language. Some of the features of python are:
1. It is a platform -independent programming language
2. It has a simple syntax
3. Python is a case-sensitive language
4. It is an interpreted language
5. It is free to use and even free for commercial products.

2. What is a variable? Discuss the rules for naming the variable


Ans. A variable is a storage location where we store values for later use in program
Rules for naming the variable:
1. Variable name must start with an alphabet (capital or small) or an underscore (_)
2. Variable name can consists of alphabets, digits and underscore
3. A python keyword cannot be used as a variable name
4. A variable name can be of any length.

3. Explain the different working modes of python


Ans. We can work in python in two modes.
1. Interactive mode: The instructions are executed line-by-line giving the output.
Commands are typed at command prompt.
2. Script mode: For writing lengthy programs in python, script mode is used. Using this
mode, we can create and edit python programs and can store them
for later use.

4. What are datatypes? explain any two data types in python


Ans. In Python, a Data type represents the type of data stored in a variable. Python has various
standard datatypes based on the type of value stored in memory.
1. Int(integer): it represents integer numbers(numbers without fractional part)
2. str(String): A string data type represents strings of characters enclosed within
quotation marks(single( ' ') or double( " "))

5. What is the use of print() function ? discuss all the separators used with the print()
function
Ans. print() function is used to print a message or value on the output device.
Separators of print() function are:
1. ‘,' operator: when we use ',' operator, the values are displayed with a space between
them.
2. '\t'(tab space): when we use'\t' escape sequence, the values are displayed with a tab
space between them.
3. '\n'(New Line): it is used to end a line and start a new line

6. What is an interpreter? How is it different from a compiler?


Ans. Interpreter:
Interpreter converts the commands (line by line) into machine language. Then
after processing it converts the machine language into human readable form.
Compiler:
It converts all instructions at once into machine code so that they can be read and
executed by computer.

You might also like