<jupyter_start><jupyter_text>Control Flow  Find the largest of three numbers<jupyter_code>num1 = 100
num2 = 200
num3 = 1

if (num1>=num2) and (num1 >= num3):
    largest=num1
elif (num2>=num1) and (num2 >= num3):
    largest=num2
elif (num3>=num1) and (num3 >= num2):
    largest=num3
print("Largest number is ", largest)<jupyter_output><empty_output><jupyter_text>while loop  Syntax:while test_expression:    Body of while  Example<jupyter_code>#find the sum of all numbers present in the list

lst=[2,13,21,19,10]

sum_list=0
indx=0

while indx < len(lst):
    sum_list=sum_list+lst[indx]
    indx+=1

print("Total sum is {}".format(sum_list))<jupyter_output><empty_output><jupyter_text>While loop with else<jupyter_code>lst=[2,13,21,19,10]

indx=0

while indx<len(lst):
    print(lst[indx])
    indx+=1
else:
    print("Items finished in the list. Index is {}".format(indx))

# what happens if we forget to increase the index
lst=[2,13,21,19,10]

indx=0

while indx<len(lst):
    print(lst[indx])
#     indx+=1
else:
    print("Items finished in the list. Index is {}".format(indx))<jupyter_output>2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
[...]<jupyter_text>Program to check if a number is prime<jupyter_code>num=int(input("Enter a number"))

div=2
isDivisibe=False

while div<num:
    if num%div==0:
        isDivisibe=True
    div+=1
    
if isDivisibe:
    print("{} is not a prime number".format(num))
else:
    print("{} is a prime number".format(num))<jupyter_output><empty_output><jupyter_text>Python For LoopUsed to iterate over sequence/listsfor element in sequence:        body of For<jupyter_code>#find the sum of numbers in a list
lst=[21,12,13,14,90]



for element in lst:
    print(element)
    #whatebe you want 
    #with element
    if element%2==1:
        print("{} is odd".format(element))<jupyter_output>21
21 is odd
12
13
13 is odd
14
90<jupyter_text>range() functionWe can generate a sequence of numbers using range() fuction.range(10) will generate numbers from 0 to 9. Therefore 10 numbers<jupyter_code>#print range of 10
for i in range(4):
    print(i)
# print range of numbers from 1 to 20, eith increment of 2
for i in range(0,10,2):
    print(i)
#Apply the range function to iterate through list
fruit_list=["mango","apple","banana","grapes","strawberry"]

print(len(fruit_list))
#what are the two ways we can print this list
for i in range(len(fruit_list)):
    print(fruit_list[i])<jupyter_output>mango
apple
banana
grapes
strawberry<jupyter_text>for loop with else<jupyter_code>vals=[12,21,13]
for val in vals:
    print(val)
else:
    print('no items are left')<jupyter_output>12
21
13
no items are left<jupyter_text>Code to display all prime numbers between an interval<jupyter_code>#should contain a nested for loop<jupyter_output><empty_output><jupyter_text>Example of continue<jupyter_code>#print odd numbers present in a list
#use continue
list_num=[21,13,14,15,20,19,16]

for my_num in list_num:
#     print(my_num)
    if my_num%2==1:
        print(my_num)
#print if a number is prime
#use break
#print numbers till 5

num=23

for i in range(2,num):
    if num%i==0:
        break
    print(i)<jupyter_output>2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{'fraction_non_alphanumeric': 0.08833413346135381, 'fraction_numerical': 0.1613058089294287, 'mean_word_length': 2.9535104364326377, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '9967', 'license': 'MIT', 'n_tokens_mistral': 2280, 'n_tokens_neox': 2196, 'n_words': 846, 'path': 'class_materials/class_2/Class 2.ipynb', 'repo_name': 'ashhadulislam/ML_Course_public', 'size': '4166'}