Question

In: Computer Science

Create a Python program that includes each feature specified below. Comments with a detailed description of...

Create a Python program that includes each feature specified below.

  • Comments with a detailed description of what the program is designed to do in a comment at the beginning of your program.
  • Comments to explain what is happening at each step as well as one in the beginning of your code that has your name and the date the code was created and/or last modified.
  • The use of at least one compound data type (a list, a tuple, or a dictionary).
  • Use of at least one method with your compound data type.
  • Use of at least one Python built-in function with your compound data type.
  • An if statement with at least two elif statements and an else statement.
  • A nested if statement.
  • At least one value input by the user during the program execution.
  • At least one result reported to the user, that varies based on the value(s) that they input.

Solutions

Expert Solution

The Python program

====================

OUTPUT

====================

RUN1:

RUN2:

The below pyhto program will do the following: 1. take entry from user on how many numbers to be added in list 2. number will be added in the list based on addition of random int with current number in range (use of if,elif) 3. list will be sorted in ascending open 4. A user defined function will be used to check which numbers in the list are greater than user provided number 5. Random number will be taken from list 6. Number will be checked for Even or odd. If even divisibility of number will be checked using nesed if. 6 13 15 16 18 #Function: printElementsGreater ThanNumber #It prints all the numbers in the list listToCheck #and prints all those numbers greater than numberToCheck def printElementsGreater ThanNumber(numberToCheck, listToCheck): updList = [] for x in listToCheck: if (x > numberToCheck): updList.append(x) #endif #endfor print("The numbers greater than ", numberToCheck, "are: ", updList) #end

#the program starts here import random theList = [] #empty list #take entry from user num = int (input("How many numbers to be created?")) #populate the list vased on value in the range o to (num-1) for x in range(num): #add element in list checking divisibility by 2,3,5 #append() is an inbuild list function: #it will add element at the end of list #random.randomint(m,n) will provide int between m and n #the if elif statement starts here if(x%2==0): theList.append(x+random.randint(1,10)) elif(x%3==0); theList.append(x+random.randint(10,20)) elif(x%5==0): theList.append(x+random.randint(20,30)) else: theList.append(x+random.randint(1,30)) #end of for loop 48 49 #print the list print("The list created is:", theList) 50 52 53 #print sum of elements in list print("The sum of elements in list: ", sum(thelist))

#sort the list in ascending order and print theList.sort() print("Sorted List: ", theList) #take number from user and print numbers in the list which are #greater than the entereed number numberToCheckwith-int(input("Enter number to check with:")) #the function printElementsGreater ThanNumber will be called here printElementsGreaterThanNumber(numberToCheckwith, theList) #get random index from the list and get the number in that index #and print that number index = random.randint(0, len(thelist)-1) theNumber = theList[index] print("The number @ random index# ", index, "of list is: ", theNumber) #check if that random number in the list is EVEN or ODD #also check the divisibility of the number in the nexted if if(theNumber%2==0): print("The number is EVEN") if(theNumber % 3 ==0): print("The number is divisible by 3") if(theNumber % 4 ==0): print("The number is divisible by 4") if theNumber % 5 ==0): print("The number is divisible by 5") if( theNumber % 7 ==0): print("The number is divisible by 7") else: print("The number is ODD") #end outer if #end of program

How many numbers to be created?8 The list created is: [7, 6, 8, 19, 7, 29, 9, 16] The sum of elements in list: 101 Sorted List: (6, 7, 7, 8, 9, 16, 19, 291 Enter number to check with:15 The numbers greater than 15 are: 116, 19. 291 The number @ random index# 7 of list is: 29 The number is ODD

How many numbers to be created?10 The list created is: [6, 6, 6, 23, 12, 35, 8, 29, 11, 23] The sum of elements in list: 159 Sorted List: [6, 6, 6, 8, 11, 12, 23, 23, 29, 35] Enter number to check with:10 The numbers greater than 10 are: (11, 12, 23, 23, 29, 35] The number @ random index# 3 of list is: 8 The number is EVEN The number is divisible by 4


Related Solutions

Develop a python program to create a quiz with limited time and attempts!!! Add comments and...
Develop a python program to create a quiz with limited time and attempts!!! Add comments and screenshot of running the program quiz could be of anything like , what's the sum of 2&2. There should be number of attempts(limited) suppose if the answer is wrong.
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and...
Challenge: Documents Description: Create a class in Python 3 named Document that has specified attributes and methods for holding the information for a document and write a program to test the class. Purpose: The purpose of this challenge is to provide experience creating a class and working with OO concepts in Python 3. Requirements: Write a class in Python 3 named Document that has the following attributes and methods and is saved in the file Document.py. Attributes __title is a...
Description of the Assignment: Write a Python program to (a) create a new empty stack. Then,...
Description of the Assignment: Write a Python program to (a) create a new empty stack. Then, (b) add items onto the stack. (c) Print the stack contents. (d) Remove an item off the stack, and (e) print the removed item. At the end, (f) print the new stack contents: Please use the following comments in your python script: # ************************************************* # COP3375 # Student's full name ( <<< your name goes here) # Week 8: Assignment 1 # ************************************************* #...
Complete the class as specified to complete the linear interpolation algorithm in python. The comments within...
Complete the class as specified to complete the linear interpolation algorithm in python. The comments within the function definitions should specify what to do. class interpolation: def linear_interpolation(self, pt1, pt2, unknown): """Computes the linear interpolation for the unknown values using pt1 and pt2 take as input pt1: known point pt1 and f(pt1) or intensity value pt2: known point pt2 and f(pt2) or intensity value unknown: take and unknown location return the f(unknown) or intentity at unknown""" #Write your code for...
Comments : For each function in your program, you must include a comment block that includes...
Comments : For each function in your program, you must include a comment block that includes a name of the function, the input parameters of the function, and the return type of the function. Use short phrase descriptions to describe each. Guard Conditions and Exception Handling: This time, your program must guard against common errors. An empty vector cannot be used for a variance or standard deviation. A file must be opened correctly. A file must be written to correctly....
Write a program using python that loops over each file in a specified directory and checks...
Write a program using python that loops over each file in a specified directory and checks the size of each file.You should create 2-tuple with the filename and size, should append the 2-tuple to a list, and then store all the lists in a dictionary.  
Challenge: Dog Description: Create a Dog class that contains specified properties and methods. Create an instance...
Challenge: Dog Description: Create a Dog class that contains specified properties and methods. Create an instance of Dog and use its methods. Purpose: This application provides experience with creating classes and instances of objects in C#. Requirements: Project Name: Dog Target Platform: Console Programming Language: C# Documentation: Types and variables (Links to an external site.) (Microsoft) Classes and objects (Links to an external site.) (Microsoft) Enums (Links to an external site.) (Microsoft) Create a class called Dog. Dog is to...
Write a paper about a health history narrative that includes a detailed description of all the...
Write a paper about a health history narrative that includes a detailed description of all the following components • Demographic data • Reason for care • Present illness • Perception of health • Past medical history • Family medical history • Review of systems • Developmental considerations • Cultural considerations • Psychosocial considerations • Collaborative resources
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Write a Python program (with comments) to do the following: Assign the value '2+1' to a...
Write a Python program (with comments) to do the following: Assign the value '2+1' to a variable str1. Use the eval() function to evaluate str1and assign the result to a variable num1. Ask the user to input their birth month and assign it to a variable month and then print it with a suitable message. Determine the number of letters in month and display the result with a suitable message. Determine how many times the letter 'r ' occurs in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT