logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Raymond BarbeauGeneral article writing
(5/5)

750 Answers

Hire Me
expert
Brayden JamesComputer science
(5/5)

753 Answers

Hire Me
expert
Tutor For YouEconomics
(5/5)

811 Answers

Hire Me
expert
Kate DuggannMathematics
(5/5)

508 Answers

Hire Me
Data structures & Algorithms
(5/5)

Write pseudocode and draw a flowchart of an algorithm to compute 1 + 3 + 5

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Introduction to Data Science Homework 4

Note: Please submit all of your codes and answers in one Jupyter Notebook file. Your codes must be executable, i.e., having no run-time errors. Questions 3, 4, and 5 are to write Python scripts. Please use a drawing tool (any) to draw your flowchart and insert its image into your submitted Jupyter Notebook file (hand-drawing is not allowed).

Question 1 (20 pts): Write pseudocode and draw a flowchart of an algorithm to compute 1 + 3 + 5

+ ... + (2n + 1), where n is an input.

Question 2 (20 pts): Consider the following Python code to print out a Fibonacci sequence. What is the problem size of the code? Explain your answer. Derive the Big-O of the code’s time complexity. Explain your derivation.

 

 

Question 3 (40 points):

a) Use a while loop to prompt the user to enter a number and if-else statements to print out that number or an error message if the input is not a number. Stop the loop after “quit” is entered.

b) Calculate 2n using a for loop (NOT using a Python built-in function to compute the power).

 

c) Calculate 1 + 2 + 22 + ... + 2n using a while loop.

d) Derive the time complexities of the programs for (b) and (c) in Big-O. Explain your derivation.

Question 4 (20 points):

a) Create an empty text file in the same folder as your .py script. Name it my_info.txt. Print out a prompt “Tell us about yourself” and then use a while loop to enter and write to the text file your information, such as your first and last names, department, program degree, hobby, ..., one by one in each iteration. Enter “quit” to exit the loop.

b) Open the text file obtained in a). Read and print out all the contents of the file.

Question 5 (bonus; 10 points): Read the first line of the text file created in Question 4, which contains your first and last names.

a) Return the position of the first letter of your last name.

b) Check the first letters of your first and last names. If either of them is in the lowercase, convert them into the uppercase. Then print out the names.

 

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme