ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 9.00

Use a loop to store the amounts in a list

Problem 14. Ask the user to enter a store’s sales for each day of the week. Use a loop to store the amounts in a list. Use a loop to calculate the total sales for the week and display the result. [Note: You are not allowed to use the sum() function.] [20 points]

 

Sample program output:

Enter sales for day 1: 2000 Enter sales for day 2: 1000 Enter sales for day 3: 2500 Enter sales for day 4: 3400 Enter sales for day 5: 4600 Enter sales for day 6: 1100 Enter sales for day 7: 2200 Total sales for the week: 16800

Problem 15. Ask the user to enter a series of 10 numbers separated by space. The program should store the numbers in a list and then display the following: [20 points]

• The lowest number in the list

• The highest number in the list

• The total of the numbers in the list

• The average of the numbers in the list

[Note: You may make use of inbuilt functions.]

 

Sample program output:

Enter 10 numbers (separate by space): 21 54 77 10 34 45 91 66 2 12 Lowest: 2 Highest: 91 Total: 412 Average: 41.2 CMPSC 101 Instructor: Dr. Mahfuza Farooque Introduction to Programming in Python Fall 2016

Problem 16. Write a python script to check whether a list is already sorted in decreasing order or not. [20 points]

 

Sample program output I:

Enter some numbers: 3 2 1 4 5 6 The list is not sorted

 

Sample program output II:

Enter some numbers: 45 34 23 4 The list is sorted

Problem 17. Ask the user to enter his first name and surname on a single line. Save the first name and surname in a list and print out the list. Ask the user to enter middle name. Insert the middle name in the list in the proper position and print the list again. [20 points]

 

Sample program output:

Enter first name and surname: Harry Potter [‘Harry’, ‘Potter’] Enter middle name: James [‘Harry’, ‘James’, ‘Potter’]

Problem 18. Write a python script to generate 1000 random digits (0 - 9) and display the count for each digit. [25 points]

[Hint: Use a list of size 10 initialized to all 0s, where each index corresponds to the digit, and update the counts of the digits accordingly.]

 

Sample program output:

0: 108 1: 113 2: 98 3: 98 4: 100 5: 96 6: 91 7: 95 8: 106 9: 95 CMPSC 101 Instructor: Dr. Mahfuza Farooque Introduction to Programming in Python Fall 2016

Problem 19 (Extra credit). Write a python script to enter a string of characters

(without any whitespace, but can include digits). Print out a list of the distinct letters from the entered string. [25 points]

[Hint: Start with an empty list. Read each character from the string and add it to the list only if it is a letter (read up on isalpha()), and it is not in the list.]

 

Sample program output:

Enter a string: abBA113av6 The distinct letters are [‘a’, ‘b’, ‘B’, ‘A’, ‘v’]

 

 

CMPSC 101Instructor: Dr. Mahfuza FarooqueIntroduction to Programming in PythonFall 2016Homework 6 – ListsDue on Wednesday, November 30, 2016 11:59 AM (Noon)Instructions:Solve problems 1 - 13 on paper or docx file (no scripts required). For problems 14 - 19 write Pythonscripts (.py files). The code and output screenshot should also be present in the docx file. Use variables wherenecessary and give meaningful names to variables. All script files should have a comment block at the top, and alsoprovide comments alongside your code. Upload a .pdf/.docx file containing your solutions along with your .py files.If you solve on paper, please upload a good quality scan using CamScanner/Office Lens/iScanner.Problem 1.What will be the output of the following code?[2 points]numbers = [10] * 5print(numbers)Problem 2.What will be the output of the following code?[2 points]numbers =list(range(1, 20, 2))print(numbers)Problem 3.What will be the output of the following code?[2 points]numbers = [1, 2, 3, 4, 5]print(numbers[-2])Problem 4.What will be the output of the following code?[2 points]numbers1 = [1, 2, 3]numbers2 = [10, 20, 30]numbers2 += numbers1print(numbers1)print(numbers2)Problem 5.What will be the output of the following code?[2 points]numbers = [1, 2, 3, 4, 5]myList = numbers[:]print(myList)Problem 6.What will be the output of the following code?[2 points]numbers = [1, 2, 3, 4, 5]myList = numbers[-3:]print(myList)Problem 7.What will be the output of the following code?[2 points]names = ['Jim','Jill','John','Jasmine']if'Jasmine'not innames:print('Cannot find Jasmine')else:print('Jasmine\'s family:')print(names)

 

Answers

(11)
Status NEW Posted 08 May 2017 01:05 AM My Price 9.00

-----------

Not Rated(0)