Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

(1) What's the Time

Build a Python script that tells you the current time.
  1. Create a new script called current_time.py in Jupyter or a text editor.
  2. Add a docstring to the script to explain what it does.
  3. Import the datetime module.
  4. Get the current time using datetime.now().
  5. Print the result, but only if the script is to be executed. *** hint, __name__==__main__
  6. Execute the script in the terminal to check if it prints the time.
  7. Import the time into a Python console and check if the console output does not print the time.

The output of the terminal should be in this format: HH:MM:SS.SSSSSS

In [ ]:
 

 

(2) Formatting Customer Names

Build a function that displays a customer's name and location if applicable
Suppose that you are building a Customer Relationship Management (CRM) system, and you want to display a user record in the following format: John Smith (California). However, if you don't have a location in your system, you just want to see "John Smith." Create a format_customer() function that takes two required positional arguments, first_ name and last_name, and one optional keyword argument, location. It should return a string in the required format.
  1. Create the customer.py file.
  2. Define the format_customer() function.
  3. Open a Python shell (Or Jupyter Notebook) and import your format_customer() function.
  4. Try running a few examples. The calls should look like this:

    from customer import format_customer
    format_customer('John', 'Smith', location='California')

    and the output should look like this:

    John Smith (California)
In [ ]:
 

 

(3) The Fibonacci Function with an Iteration

Calculate a Fibonacci sequence
You work in an IT firm, and your colleague has realized that being able to quickly compute elements of the Fibonacci sequence will reduce the time taken to execute the testing suite on one of your internal applications. You will use an iterative approach to create a fibonacci_iterative function that returns the nth value in the Fibonacci sequence.
  1. Create a fibonacci.py file.
  2. Define a fibonacci_iterative function that takes a single positional argument representing which number term in the sequence you want to return.
  3. Run the following code:

from fibonacci import fibonacci_iterative
fibonacci_iterative(3)
You should get the following output:
2
Another example to test your code can be as mentioned in the following code snippet:

fibonacci_iterative(10)


You should get the following output:
55

In [ ]:
 

 

(4) The Fibonnaci Function with Recursion

Remake your previous fibonacci program as a recursive function
In [ ]:
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education