×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Consonant count in String Assignment 2 of South Point School List in Python
Assignment of South Point School List in Python - Python Language
1674    Arnab De    16/11/2020

Write a Python program to initialize a list with the following values in the code: L = [6, 8, 23, 45, 27, 4, 19, 34, 24, 5, 20, 10, 32, 15, 18, 21] Next ask the user to input a number N between 1 and 50 (both inclusive). Next, generate a random number R between 1 and N using the randint( ) function. Finally check the list to see if the randomly generated number R is present in the list or not. If it is present, then print the list index where it is present. Otherwise print ‘NNNNNN says the number is not present in the list’, where NNNNNN is YOUR FULL NAME. Give the output of the code for both cases.

School Assignment 2020: South point School

softetechnologies
import random
L = [6, 8, 23, 45, 27, 4, 19, 34, 24, 5, 20, 10, 32, 15, 18, 21]
N=int(input("Enter A Number ( between 1 to 50): "))
if(N>=1 and N<=50):
	r=random.randint(1,N)
	fl=0;
	index=0;
	for i in L:
		if(i==r):
			fl=1
			break;
		index=index+1;
    if(fl==1):
        print("Generated Random Number ",r ," is found at index no ",index)
    else:
        print("Arnab says  number  is  not  present  in  the  list")
else:
    print("You Should Enter a number Between 1 to 50")
softetechnologies
Consonant count in String Assignment 2 of South Point School List in Python
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Swami Vivekananda
Fill the brain with high thoughts, highest idrals, place them day and night before you, and out of that will come great work.
Swami Vivekananda
758
79.58
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     53865
25/06/2018     44935
01/01/2018     43513
28/06/2017     41083
02/08/2017     40054
01/08/2017     34103
06/07/2017     33938
15/05/2017     33182
11/09/2018     29969
14/07/2017     29646
softetechnologies