Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Part 2

Write your own function that illustrates a feature that you learned in this unit. The function must take at least one argument. The function should be your own creation, not copied from any other source. Do not copy a function from your textbook or the Internet.

Include all of the following in your Learning Journal:

  • The code for the function that you invented.
  • The inputs and outputs to three calls of your invented function.
  • A description of what feature(s) your function illustrates.  

Part 1

The volume of a sphere is 4/3πr3, where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called print_volume (r) that takes an argument for the radius of the sphere, and prints the volume of the sphere.

Call your print_volume function three times with different values for radius.

Include all of the following in your Learning Journal:

  • The code for your print_volume function.
  • The inputs and outputs to three calls of your print_volume.

Write four classes: Address, Person, Contact, and Notebook.

Address takes as parameters the street name and city. A person has a name and email address. Both classes have methods to print the information.

Derive the Contact class from Address and Person. Use their methods to print the information for a contact.

In the Notebook class, create a dictionary named person to store the contact information (name as key, <name, email, street, city> as value). Create a method to print the information for the called person. If the name is not found in the dictionary, print Unknown.


write a program to achieve advanced encryption standard 128 bit key length encoding and decoding a text. in that we can't use any package or import functions. the code based on that algorithm only

Input text

“To be, or not to be, that is the question:

Whether 'tis nobler in the mind to suffer

The slings and arrows of outrageous fortune,

Or to take arms against a sea of troubles

And by opposing end them. To die—to sleep,

No more; and by a sleep to say we end

The heart-ache and the thousand natural shocks

That flesh is heir to: 'tis a consummation

The pangs of dispriz'd love, the law's delay,

The insolence of office, and the spurns

That patient merit of th'unworthy takes,

When he himself might his quietus make

And thus the native hue of resolution

Is sicklied o'er with the pale cast of thought,

And enterprises of great pith and moment

With this regard their currents turn awry

And lose the name of action.”


Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. Try to be creative with your examples to demonstrate that you invented them yourself.



  • Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.

184 words


Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. Try to be creative with your examples to demonstrate that you invented them yourself.


  • Example 1: Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.
  • Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which. 
  • Example 3: Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.
  • Example 4: Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.

The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.


output

If the given operator is "+", print the sum of two numbers.

If the given operator is "-", print the result of the subtraction of the two numbers.

If the given operator is "*", print the multiplication of the two numbers.

If the given operator is "/", print the result of the division of the two numbers.

If the given operator is "%", print the result of the modulus operation of the two numbers.


Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.


Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.


Write a Python program that solves the travelling salesperson problem.


Sample output:

Input: cost for every path:

Cost from 1-2: 10

Cost from 1-3: 15

Cost from 1-4: 20

Cost from 2-3: 35

Cost from 2-4: 25

Cost from 3-4: 30


Output:

Optimal Route: 12431

Total Path Cost: 80




LATEST TUTORIALS
APPROVED BY CLIENTS