From 9a2aea94e2efc47b7eefffce2e8ffda5fda74138 Mon Sep 17 00:00:00 2001 From: arvind-27 Date: Tue, 20 Oct 2020 14:34:55 +0530 Subject: [PATCH 1/2] i have written the code for linear change in python --- Linear Search/16123004.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Linear Search/16123004.py b/Linear Search/16123004.py index de2146a..c81a73d 100644 --- a/Linear Search/16123004.py +++ b/Linear Search/16123004.py @@ -1,8 +1,13 @@ k = 4 l = [ 2,3,4,5,6,8] - +flag=0 n = len(l) -for i in n: - # TODO Fill Code here +for i in range(n): + if l[i] == k: + flag=1 + print("found") + break +if(flag==0): + print("the number is not in the list") From 2ab2c329a4385cfc26f008d4baf1a714311582fb Mon Sep 17 00:00:00 2001 From: arvind-27 Date: Tue, 20 Oct 2020 14:40:38 +0530 Subject: [PATCH 2/2] i have corrected the code for max which did not included range in it --- Find Max/16123004.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Find Max/16123004.py b/Find Max/16123004.py index 7e98aef..50628d3 100644 --- a/Find Max/16123004.py +++ b/Find Max/16123004.py @@ -2,7 +2,7 @@ n = len(l) curr_max = 0 -for i in n: +for i in range(n): # TODO Fill Code here if l[i] > curr_max: curr_max = l[i]