0% found this document useful (0 votes)
14 views1 page

Python Basics: Numbers and Strings

Uploaded by

govindbaghel7455
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)
14 views1 page

Python Basics: Numbers and Strings

Uploaded by

govindbaghel7455
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

Chapter 2 - Practice set

1. write a python program to add two numbers.


2. write a python to find remainder when a number is divided by b.
3. Check the type of variable assigned using input () function.
4. Use comparison operator to find out whether a given variable a is greater than
'b' or not. Take a=34 and b=80
5. Write a python program to find an average to two nubers entered by the user.
6. Write a python program to calculate the square of a number entered by the user.

Chapter 3 - Strings
We can primarily write a string in these three ways.
a= ‘gagan’
b= “gagan”
c= “’gagan”’

consider the following string.

Name= “G a g a n” length=5
01234
(-5)(-4)(-3)(-2)(-1)

sl = name[ind_start: ind_end]
first index included last index is not included

sl [0:3] returns “har”----- characters from 0 to 3


sl [1:3] returns “ar” ----- characters from 1 to 3

Negative indices: Negative indices can also be used an shown in the figure above, -
1 corresoonds to the (length- 1) index,-2 to (length- 2).

You might also like