Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal of this programming exercise is to get you more comfortable with using Jupyter Notebook and to begin using simple elements of Python. Standard

The goal of this programming exercise is to get you more comfortable with using Jupyter Notebook and to begin using simple elements of Python. Standard elements of a program include the ability to print out results (using the print operation), the ability to read input from a user at the console (for example using the input function), and the ability to store values in a variable, so that the program can access that value as needed. A Very Simple Program: Raising a number to a power and taking a logarithm:

Write a program that does the following in order: Asks the user to enter a number x Asks the user to enter a number y Prints out number x, raised to the power y. Prints out the log (base 2) of x.

Hints: To see how to use the print command, you may find it convenient to look at the input and output of the Python Wikibook. This will show you how to use print statements to print out values of variables. To see how to read input from the user into the Jupyter Notebook Python environment, you may find it convenient to look at the same section (see for example the input(...) function) Reference the basic math section of the Python Wikibook to read more about using basic mathematical operators in Python To take the logarithm of a variable, import either of the numpy or pylab packages. You can then call either numpy.log2 or pylab.log2 to calculate the logarithm. See the Getting Started document on importing packages and the many Numpy examples online for more info. Googling the log2 function may take you here, which has some helpful info. Remember that if you want to hold onto a value, you need to store it in a variable (i.e., give it a name to which you can refer when you want that value). You may find it convenient to look at the variables and strings section of the Python Wikibook. (As you read through, remember that in Python 3.x you should be using input() not raw_input()). Use this Jupyter Notebook below to create your Python program, and save your notebook and upload it on Blackboard.

An example of an interaction with your program is shown below. The words printed in blue are ones the computer should print, based on your commands, while the words in black are an example of a user's input. The colors are simply here to help you distinguish the two components.

Enter number x: 2 Enter number y: 3 X**y = 8 log(x)= 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Developing and delivering learning that is integrated with the job.

Answered: 1 week ago

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago