0% found this document useful (0 votes)
137 views26 pages

Ge3151 Python Unit3

GE3151_UNIT 3

Uploaded by

Muppudathi R
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)
137 views26 pages

Ge3151 Python Unit3

GE3151_UNIT 3

Uploaded by

Muppudathi R
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/ 26

UNIT III

CONTROL FLOW, FUNCTIONS, STRINGS


Conditionals: Boolean values and operators, conditional (if), alternative (if-else), chained
conditional (if-elif-else); Iteration: state, while, for, break, continue, pass; Fruitful functions:
return values, parameters, local and global scope, function composition, recursion; Strings:
string slices, immutability, string functions and methods, string module; Lists as arrays.
Illustrative programs: square root, gcd, exponentiation, sum an array of numbers, linear search,

3.1 CONDITIONALS
3.1.1 Boolean Values
 Boolean data types have two values. They are 0 and 1.
 0 represents False and 1 represents True. True and False are keywords.
 Relational operators such as ==, !=,>,<,>=,<= and the logical operators such as and, or, not
are the Boolean operators

Example:
>>> 3==5
False
>>> 6==6
True
>>> True+True
2
>>> False+True
1
>>> False*True
0

>>> x=True
>>> y=False
>>> x and y
False
>>> x or y
True
>>> not x
False
>>> not y
True

3.1.2 CONDITIONALS COMMANDS


1. Conditional if
2. Alternative if…. else
3. Chained if…elif…else
4. Nested if …else

1
1 Conditional (if):
Conditional (if) is used to test a condition, if the condition is true the statements inside if will
be executed.
syntax:

Flowchart:

Example:
 Program to provide flat rs.500, if the purchase amount is greater than 2000.
 Program to provide bonus mark if the category is sports.

Program to provide flat rs.500, if the purchase amount Output


is greater than 2000.
purchase=eval(input(“ enter your purchase amount” )) enter your purchase amount
if(purchase>=2000):
purchase=purchase-500 2500
print( “amount to pay” ,purchase) amount to pay
2000
Program to provide bonus mark if the category is Output
Sports
m=eval(input(“ enter your mark out of 100” )) enter your mark out of 100
c=input(“ enter your category G/S” ) 85
if(c== S ): enter your category G/S
m=m+5 S
print( “mark is” ,m) mark is 90

2 Alternative (if-else)
 In the alternative if-else, the condition must be true or false.
 In this, else statement can be combined with if statement.
 If the condition is true, statements inside the if get executed otherwise else part gets
executed.
syntax: Flowchart:

2
Examples
1. odd or even number
2. positive or negative number
3. leap year or not
4. Greatest of 2 numbers
5. Eligibility for voting

1. odd or even number Output

n=eval(input("enter a number")) enter a number 4


if(n%2==0): even number
print("even number")
else:
print("odd number")

2 positive or negative number Output

n=eval(input("enter a number")) enter a number 8


if(n>=0): positive number
print("positive number")
else:
print("negative number")

3 leap year or not Output

y=eval(input("enter a year")) enter a year2000


if(y%4==0): leap year
print("leap year")
else:
print("not leap year")

4 Greatest of 2 numbers Output

a=eval(input("enter a value:")) enter a value: 4


b=eval(input("enter b value:")) enter b value: 7
if(a>b): greatest: 7
print("greatest:",a)
else:
print("greatest:",b)

5 Eligibility for voting Output

age=eval(input("enter your age:")) enter your age:78


if(age>=18): you are eligible for vote
print("you are eligible for vote")
else: enter your age:16
print("you are not eligible for vote") you are not eligible for vote
3
3 Chained conditionals (if-elif-else)
 The elif is short for else if.
 It is used to check more than one condition.
 If the condition1 is False, it checks the condition2 of the elif block.
 If all the conditions are False, then the else part is executed.
 Among the several if...elif...else part, only one part is executed according to the condition.
 The if block can have only one else block. But it can have multiple elif blocks.
 The way to express a computation like that is a chained conditional. The Syntax as follows

Flowchart:

Example:
1. student mark system
2. traffic light system
3. compare two numbers
4. roots of quadratic equation

1. Student mark system OUTPUT

mark=eval(input("enter your mark:")) enter your mark: 78


if(mark>=90): grade: B
print("grade: S")
elif(mark>=80):
print("grade: A")
elif(mark>=70):
print("grade: B")
elif(mark>=50):
print("grade: C")
else:
print("fail")

4
2. Traffic light system
Output
colour=input("enter colour of light:") enter colour of light: green
if(colour=="green"): GO
print("GO")
elif(colour=="yellow"):
print("GET READY")
else:
print("STOP")
Output
3 Compare two numbers

x=eval(input("enter x value:")) enter x value: 5


y=eval(input("enter y value:")) enter y value: 7
if(x == y): x is less than y
print("x and y are equal")
elif(x < y):
print("x is less than y")
else:
print("x is greater than y")
Output
4 Roots of Quadratic equation
enter a value:1
a=eval(input("enter a value:")) enter b value:0
b=eval(input("enter b value:")) enter c value:0
c=eval(input("enter c value:")) same and real roots
d=(b*b-4*a*c)
if(d==0):
print("same and real roots")
elif(d>0):
print("different real roots")
else:
print("imaginary roots")

4Nested conditionals

 One conditional can also be nested within another. Any number of conditions can be nested
inside one another.
 In this, if the condition is true it checks another if condition1.
 If both the conditions are true, statement1 gets executed otherwise statement2 gets
executed.
 If condition is false statement3 gets executed
Syntax

5
Flowchart:

Example

1. Greatest of three numbers


2. Positive or Negative or Zero

1 Greatest of three numbers Output

a=eval(input(“ enter the value of a” )) enter the value of a 9


b=eval(input( “enter the value of b” )) enter the value of a 1
c=eval(input(“ enter the value of c “)) enter the value of a 8
if(a>b): the greatest no is 9
if(a>c):
print( “the greatest no is” ,a)
else:
print( “the greatest no is “,c)
else:
if(b>c):
print( “the greatest no is “,b)
else:
print(“ the greatest no is” ,c)

2 Positive or Negative or Zero Output


n=eval(input("enter the value of n:")) enter the value of n:-9
if(n==0): the number is negative
print("the number is zero")
else:
if(n>0):
print("the number is positive")
else:
print("the number is negative")

6
3.2 ITERATION
3.2.1 Iteration statements
1. while
2. for
State: Transition from one process to another process under specified condition with in a time
is called state. The state variable or the variable in the loop undergoes change for each iteration.
1. While: While loop statement in Python is used to repeatedly executes set of statement as
long as a given condition is true.
 In while loop, test expression is checked first. The body of the loop is entered only if the
test expression is true.
 After one iteration the test expression is checked again. This process continues until the
test expression evaluates to False.
 In Python, the body of the while loop is determined through indentation.

Syntax:

Flowchart

else in while loop


 If else statement is used within while loop, the else part will be executed when the condition
become false.
 The statements inside for loop and statements inside else will also execute.

Program Output
i=1 1
while(i<=5): 2
print(i) 3
i=i+1 4
else: 5
print("the number is greater than 5") the number is greater than 5

7
Nested while
 While inside another while is called nested while
Syntax

Nested While ( to print a pattern): Output


i=1
while (i<=4): 1
j=1 1 2
while (j<=i): 1 2 3
print(j,end=" ") 1 2 3 4
j=j+1
print( )
i=i+1
Examples
1. program to find sum of n numbers:
2. program to find factorial of a number
3. program to find sum of digits of a number:
4. Program to Reverse the given number:
5. Program to find number is Armstrong number or not
6. Program to check the number is palindrome or not

1 Sum of n numbers Output

n=eval(input("enter n")) enter n


i=1 10
sum=0 55
while(i<=n):
sum=sum+i
i=i+1
print(sum)
2 Factorial of a number Output

n=eval(input("enter n")) enter n 5


i=1 120
fact=1
while(i<=n):
fact=fact*i
i=i+1
print(fact)

8
3 Sum of digits of a number Output
n=int(input("enter the number")) enter a number
sum=0 123
while (n>0): 6
a=n%10
sum=sum+a
n=n//10
print(sum1)
4 Reverse of the given number Output

n=int(input("enter the number")) enter a number


rev=0 123
while( n>0): 321
a=n%10
rev=(rev*10)+a
n=n/10
print(rev)

5 Armstrong number or not Output

n=int(input("enter the number")) enter a number 153


arm=0 given number is Armstrong number
org=n
while (n>0):
a=n%10
arm=arm+(a*a*a)
n=n//10
If (org==arm):
print(n, "is a Armstrong number")
else:
print(n, "is not Armstrong")
6 Palindrome or not
n=int(input("Enter a number:")) enter a number121
org=n The given no is palindrome
rev=0
while(n>0):
a=n%10
rev=(rev*10)+a
n=n/10
if(org==rev):
print("The number is palindrome")
else:
print("The number is not palindrome")

9
For Loop
For loop statement in Python is used to repeatedly execute set of statement as long as the given
condition is true. For statement iterate over a range of values or sequence (String, List, Tuple)

Syntax :
for variable in range() :
body of for loop

The different methods of using for loop in Python are given below:
i) for in range
 We can generate a sequence of numbers using range () function. Range function have to
define the start, stop and step size as range (start, stop, step size).
 The default value of step size is 1 if not provided. The default value of start is 0.
 Range (10) will generate numbers from 0 to 9 (10 numbers).
 The body of for loop is separated from the rest of the code using indentation.

syntax

ii) For in sequence


 for loop in the Python can be used to iterate over a sequence (list, tuple, string).
 Iterating over a sequence is called traversal.
 Loop continues until we reach the last element in the sequence.
 Syntax

Example
For loop with Sequence Output
for i in "RANI": R
For loop in string print(i) A
N
I
For loop in list for i in [2,3,5,6,9]: 2
3
print(i)
5
6
9
For loop in tuple
for i in (2,3,1): 2
print(i) 3
1

10
iii) else in for loop
The else statement can be used in for loop. The else statement is executed when the loop has
reached the limit. The statements inside for loop and statements inside else will also execute.

Example Output
for i in range(1,5): 1
print(i) 2
else: 3
print("the number is greater than 4”) 4
the number is greater than 4

iv) Nested for


 for inside another for is called nested for
 The syntax for a nested for loop statement in Python programming language is as follows
Syntax

Example :

for i in range(1, 4):


for j in range(1, i+1):
print(j,end=” “)
print()
Output
1
12
123

Examples:
1. print numbers divisible by 5 not by 10:
2. Program to print Fibonacci series.
3. Program to find factors of a given number
4. check the given number is perfect number or not
5. check the no is prime or not
6. Print first n prime numbers
7. Program to print prime numbers in range

1 To print numbers divisible by 5 not by 10 Output


enter a value :30
n=eval(input("enter a value")) 5
for i in range(1,n,1): 15
if(i%5==0 and i%10!=0): 25
print(i)
11
2 Fibonacci series output
a=0 Enter the number of terms: 6
b=1 Fibonacci Series:
n=eval(input("Enter the number of terms: ")) 0
print("Fibonacci Series: ") 1
print(a) 1
print(b) 2
for i in range(2,n): 3
c=a+b 5
print(c)
a=b
b=c
3 To find factors of a number Output
enter a number:10
n=eval(input("enter a number:")) 1
for i in range(1,n+1): 2
if(n%i==0): 5
print(i) 10
4 To check the number is prime or not output
enter a no:7
n=eval(input("enter a number")) The num is a prime number.
for i in range(2,n):
if(n%i==0):
print("The num is not a prime")
break
else:
print("The num is a prime number.")
5 To check a number is perfect number or not Output
enter a number:6
n=eval(input("enter a number:")) the number is perfect number
sum=0
for i in range(1,n,1):
if(n%i==0):
sum=sum+i
if(sum==n):
print("the number is perfect number")
else:
print("the number is not perfect number")
6 To print first n prime numbers Output
number=int(input("enter no of prime enter no of prime numbers to be
numbers to be displayed:")) displayed:5
2
count=1
n=2 3
while(count<=number): 5
7
for i in range(2,n):
if(n%i==0): 11
break
else:
print(n)
count=count+1
n=n+1
12
7 To print prime numbers in range output:

lower=eval(input("enter a lower range")) enter a lower range50


upper=eval(input("enter a upper range")) enter a upper range100
for n in range(lower,upper + 1): 53
59
for i in range(2,n): 61
if (n % i) == 0: 67
Break 71
else: 73
print(n) 79
83
89
97
3.2.2 Loop Control Structures
i) break
ii) Continue
iii) pass

i) break
 Break statement can alter the flow of a loop.
 It terminates the current loop and executes the statements outside loop.
 If the loop has else statement, that will also get terminated and come out of the
loop completely.

Syntax

Flowchart

13
ii) continue
This terminates the current iteration and transfer the control to the next iteration in the loop.

Syntax:

Flowchart

3. pass
 It is used when a statement is required syntactically but you don t want any code to execute.
 It is a null statement, nothing happens when it is executed.
Syntax: pass

Examples

Break Output continue Output Pass Output

for i in "welcome": w for i in "welcome": w for i in welcome : w


if(i=="c"): e if(i=="c"): e if (i == c ): e
break l continue l Pass l
print(i) print(i) o print(i) c
m o
e m
e

Differences between break and continue


break Continue
It terminates the current loop and It terminates the current iteration and
executes the statements outside transfer the control to the next iteration
the loop. in the loop.

3.3 FUNCTIONS

a. Fruitful function: A function that returns a value is called fruitful function.


Example 1:
import math
root=math.sqrt(25) print( “Hello” )

14
Example 2:
def add():
a=10
b=20
c=a+b
return c
c=add()
print(c)

b. Void function: A function that performs action but don’t return any value is called void
function
Example 1:
print( “Hello” )
Example 2:
def add():
a=10
b=20
c=a+b
print(c)
add()
c. Return values: Return keyword is used to return the value from the function.
Examples description
return a return 1 variable
return a,b return 2 variables
return a,b,c return 3 variables
return a+b return expression
return 8 return value

Example :
def area(s):
c=s*s
return (c)
a = int (input(“Give the value of side”))
ar=area(a)
print(“Area of square=”,ar)

d. Parameter / Arguments
 Parameters are the variables/values which are used in the
function definition.
 Parameters are inputs to functions.
 Parameter receives the input from the function call.
 It is possible to define more than one parameter in the function definition.
Types of parameters:
i) Required/Positional parameters
ii) Keyword parameters
iii) Default parameters
iv) Variable length parameters

15
i) Required/ Positional Parameter: The number of parameter in the function definition
should match exactly with number of arguments in the function call.
Example
def student( name, roll ): Output: George 98
print(name,roll)
student(“ George” ,98)
ii) Keyword parameter: When we call a function with some values, these values get assigned
to the parameter according to their position. When we call functions in keyword
parameter, the order of the arguments can be changed.
Example
def student( name, roll,mark ): Output: 90 102 bala
print(name,roll,mark) bala 102 90
student( 90,102,”bala”)
student( roll=102,mark=90,name =,”bala”)

iii) Default parameter: Python allows function parameter to have default values; if the function
is called without that argument, the argument gets its default value in function definition.
Example
def student( name, age=17): Output Kumar 17
print(name,age) Ajay 17
student(“ kumar”)
student(“ ajay”)
iv) Variable length parameter. Sometimes, we do not know in advance the number of
arguments that will be passed into a function. Python allows us to handle this kind of
situation through function calls with number of arguments. In the function definition we
use an asterisk (*) before the parameter name to denote this is variable length of
parameter. Example
def student( name, *mark): Output bala (102,90)
print(name,mark)
student(“bala",102,90)
e. Local and global scope of variables in functions

The SCOPE of a variable refers to the places where you can see or access a variable.

Global scope : A variable with global scope can be used anywhere in the program.
 It can be created by defining a variable outside the function.

Example

a=50  Global variable


def add():
b=20  Local variable
c=a+b #70
print(c)
def sub():
b=30
c=a-b #20
print(c) # 50
print(a)
Local Scope: A variable with local scope can be used only within the function.
Example
def add():
a=50  Local variable
b=20  Local variable
c=a+b
print(c) #70
def sub():
print(a-b) # Err

f. Function Composition
 Function Composition is the ability to call one function from within another function
 It is a way of combining functions such that the result of each function is passed as the
argument of the next function.
 In other words, the output of one function is given as the input of another function is known
as function composition.
Example 1: Output:
def add(a,b): 900
c=a+b
return c
def mul(c,d):
e=c*d
return e
c=add(10,20)
e=mul(c,30)
print(e)

Ex 2 : Find sum and average of 2 nos using function composition

def sum(a,b): Output


return(a+b) Sum = 30
def average(c): Average= 15.0
return(c/2)
e=sum(10,20)
f=average(e)
print(“Sum =”,e)
print(“Average=”,f)

Ex 3 : x=int(input(“Give the value “))

The above statement is also function composition where, “input” is a built-in function.
The value got through input function is passed as argument to “int” function and gets
converted to integer value

g. RECURSION

A function calling itself till it reaches the base value - stop point of function call.
Example:
factorial of a given number using recursion
Factorial of n Output
def fact(n): enter no. to find factorial: 5
if(n==1): Fact is 120
return 1
else:
return n*fact(n-1)
n=eval(input("enter no. to find factorial:"))
f=fact(n)
print("Fact is ",f)

Explanation

Example
sum of n numbers using recursion
def sum(n):
if(n==1):
return 1
else:
return n+sum(n-1)
n=eval(input("enter no. to find sum:"))
sum=sum(n)
print("Sum is",sum)

h. Lambda Function or Anonymous Function:


 Lambda function is a function defined without a name.
 It can take any number of arguments but one value in the form of expression.
 Lambda function is mostly used for creating small function.

Syntax:
var = lambda arguments : expression
Example :

sum = lambda x,y : x+y


print(sum(10,20))
In the above program, lambda x,y: x+y is the Lambda function. x and y are the argument. x+y is the
expression that is evaluated and returned. . lambda function has no name. Hence it is called
anonymous function

3.4 STRINGS
 String is defined as sequence of characters represented in quotation marks (either
single quotes (‘ ‘) or double quotes (“ “ ).
 An individual character in a string is accessed using an index. The index should always be an
integer (positive or negative). The index starts from 0 to n-1.
 Strings are immutable i.e. the contents of the string cannot be changed after it is created.
 Python will get the input at run time by default as a string.
 Python does not support character data type.
 A string is enclosed within:
1. single quotes (' ')
2. double quotes (" ")
3. triple quotes (“”” “””)
String Traversal : Accessing the elements of string using its index value in for/while loop

Example:

name=”jai” j
for i in name: a
print(i) i

Operations on string
1. Indexing
2. Slicing
3. Concatenation
4. Repetitions
5. Membership

String A H E L L O
Positive Index 0 1 2 3 4
Negative Index -5 -4 -3 -2 -1

3.4.1 String Slices


 A part of a string is called substring.
 The process of extracting a sub string from a string is called slicing.

Slicing: print(a[0:4]) HELL The Slice[n : m] operator extracts sub


print(a[ :3]) HEL string from the strings.
a=”HELLO” print(a[::]) HELLO
print(a[::-1]) OLLEH
print(a[0: ]) HELLO A segment of a string is called a slice.
3.4.2. Immutability
 Python strings are immutable as they cannot be changed after they are created.
 Therefore [ ] operator cannot be used on the left side of an assignment.

20
3.4.3. String built in functions and methods:

A method is a function that belongs to an object.

Syntax to access the method:


Stringname.method()
Assume: a= “happy birthday” [Where, a is the string name]
3.4.4 String Module

 A module is a file containing Python definitions, functions, statements.


 Standard library of Python is extended as modules.
 To use these modules in a program, programmer needs to import the module.
 Once we import a module, we can reference or use to any of its functions or variables in our
code.
 There is large number of standard modules also available in python.
 Standard modules can be imported the same way as we import our user-defined modules.

Syntax: import module_name

21
Escape Sequences:
An escape sequence contains a backslash (\) symbol followed by a character. In Python, backslash ( \ )
is known as escape character because it causes an escape from the normal interpretation of the character.
When used inside a character or string, does not represent itself but is converted into another character or
series of characters like newline (\n), tab (\t), and so on.

3.5 LIST AS ARRAY


Array:
 Array is a collection of similar elements. ie An array is a special variable, which can hold
more than one value at a time. If we have a list of items (a list of car names, for example),
storing the cars in single variables could look like this:
car1 = "Ford"
car2 = "Volvo"
car3 = "BMW"
 But using single variables becomes difficult if we have more data. For eg, we have 300 cars
and not 3. The solution is an array. An array can hold many values under a single name, and
we can access the values by referring to an index number. Index starts with 0.
 Python does not have built-in support for Arrays, but Python Lists can be used instead.
 List as Arrays are used to store multiple values in one single variable
cars = ["Ford", "Volvo", "BMW"]
Access the Elements of an Array
 To refer to an array element by referring to the index number.
Example x = cars[0]
 To Modify the value of the first array item:
cars[0] = "Toyota"
 The Length of an Array
Use the len() method to return the length of an array (the number of elements in an array).
x = len(cars)
Note: The length of an array is always one more than the highest array index.
Looping Array Elements
 We can use the “for in” loop to loop through all the elements of an array.
Example : To print each item in the cars array:
for x in cars:
print(x)

22
Exampe for list as array
a=[]
for i in range(0,10):
car=input("Give the car name")
a.append(car)
for i in range(0,10):
print(a[i])

Various Methods in List as array: Let a be the list used as array


a=[10,20,30,40]

NO Syntax example Description


1 append() >>>a.append(50) This method is used to add the at
[10,20,30,40,50] the end of the array.

2 insert(index,element) >>>a.insert(2,25) This method is used to add the


[10,20,25,30,40,50] value at the position specified in its
argument.

3 pop(index) >>>a.pop(1) This function removes the element


[10, 25,40,50,60] at the position mentioned in its argument,
and returns it.

4 index(element) >>>a.index(10) This function returns the index of


0 value
5 count() a.count(25) This is used to count number of times the
1 element occur in the array

ILLUSTRATIVE PROGRAMS
1. Square root using newtons method
def newtonsqrt(n):
root=n/2
for i in range(10):
root=(root+n/root)/2
print(root)
n=eval(input("enter number to find Sqrt: "))
newtonsqrt(n)

Output
enter number to find Sqrt: 9
3.0

Method 2 :
n=int(input("Give the number"))
sqrt=n**0.5
print("Square root of",n,"is",sqrt)
Output
Give the number 9
Square root of 9 is 3.0
23
2. GCD of two numbers - Method 1
n1=int(input('Enter a number1:'))
n2=int(input('Enter a number2:'))
for i in range(1,n1+1):
if(n1%i==0 and n2%i==0):
gcd=i
print(gcd)

Output
Enter a number1: 8
Enter a number2: 24
8

#Method 2 : Program to find the gcd/hcf using recursion / Euclidean method


def gcd(a, b):
if(b == 0):
return a
else:
return gcd(b, a % b)
a=int(input("Enter first number:"))
b=int(input("Enter second number:")) GCD=gcd(a,b)
print("GCD is: ",GCD)

3. Exponent of number
base = int(input("Give the base : "))
exponent = int(input("Give the Exponent : "))
result = 1
for i in range(exponent):
result = result* base
print("Answer = ",result)

Output :
Give the base: 2
Give the Exponent: 3
Answer = 8

Method 2 : Exponent of number using recursion


def power(base,exp):
if (exp==1):
return(base)
else:
return(base*power(base,exp-1))
base=int(input("Enter base: "))
exp=int(input("Enter exponential value:"))
result=power(base,exp)
print("Result:",result)
Output
Enter base: 3
Enter exponential value:4
Result: 81

24
4. Sum of array elements
a=[2,3,4,5,6,7,8]
sum=0
for i in a:
sum=sum+i
print("the sum is",sum)

Output
the sum is 35

5. Linear Search

a=[20,30,40,50,60,70,80]
print(a)
search=eval(input("enter a element to search:"))
for i in range(0,len(a),1):
if(search==a[i]):
print("element found at",i+1)
break
else:
print("not found")

Output
[20, 30, 40, 50, 60, 70, 80]
enter a element to search:40
element found at 3

6 Binary Search

a=[20, 30, 40, 50, 60, 70, 80]


print(a)
search=eval(input("enter a element to search:"))
start=0
stop=len(a)-1
while(start<=stop):
mid=(start+stop)//2
if(search==a[mid]):
print("element found at",mid+1)
break
elif(search<a[mid]):
stop=mid-1
else:
start=mid+1
else:
print("The element is not present in the list")

Output
[20, 30, 40, 50, 60, 70, 80]
enter a element to search:50
element found at 4

25

You might also like