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

Write a program that accepts three decimal numbers as input and outputs their sum.
Copy the countdown function from Section 5.8 of your textbook.

def countdown(n):
if n <= 0:
print('Blastoff!')
else:
print(n)
countdown(n-1)

Write a new recursive function countup that expects a negative argument and counts “up” from that number. Output from running the function should look something like this:

>>> countup(-3)
-3
-2
-1
Blastoff!

Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)

If the number is positive, the program should call countdown. If the number is negative, the program should call countup. Choose for yourself which function to call (countdown or countup) for input of zero.

Provide the following.

The code of your program.
Output for the following input: a positive number, a negative number, and zero.
An explanation of your choice for what to call for input of zero.
Write your own unique Python program that has a runtime error. Provide the following.

The code of your program.
Output demonstrating the runtime error, including the error message.
An explanation of the error message.
An explanation of how to fix the error.
Describe the difference between a chained conditional and a nested conditional. Give your own example of each.


Deeply nested conditionals can become difficult to read. Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to become a single conditional, and show the equivalent single conditional.
Hi, I had a homework to do which I don't quiet understand. It's this
Write a function approx_ln(x,n) that approximates the logarithm by n steps
of the above algorithm

with these information
It is based of computing the arithmetic and geometric mean of two values ai, gi
For a given value x > 0, initialize a_0 =(1+x)/2 , g_0 =√x,
• Iterate a_(i+1) =(a_i+g_i)2 and g_(i+1) =√ai+1gi
• Consider ( x−1)/a_i as an approximation to ln(x).

and after trying a lot I came up with this

def arithmetic_geometric_mean(a, g):
while True:
a= (a+g)/2
g=sqrt(a*g)
yield a, g

tol= 1e-5
def approx_ln(x, maxit=500):
a_0= (1+x)/2
g_0=sqrt(x)
for a,b in islice(arithmetic_geometric_mean(a_0, g_0), maxit):
if abs(a-b)<tol:
return (x-1)/a

which works but the question asks for different values of n and idk what to do
"DESIGN and implement a function that takes an amount of money in UAE dirhams and return the same amount in US dollars and EUROS.research today exchange rate from the internet.If the rate are not passed to the function,use 3.68 for US dollars and 4.20 for Euros
Assignment 9: Personal Organizer on edhesive.create a personal organizer. Using parallel arrays you will store the following information on each event in your organizer:

Month (1 - 12)
Day (1 - 31)
Year
Event name
If the user enters an incorrect month the month should be set to January.
If the user enters an incorrect day then the day should be set to 1.

Write the following methods:

Add an event
Print all events
Print events in a specific month
Your program should follow how the sample run (below) asks for input and how it outputs events.

It should first keep asking for new events to add until the user says NO. Then, it should print all the events entered. Finally, it should ask the user for a specific month that he or she would like to see events from.
In this assignment, you will draw a student schedule by using a while loop. You will ask the user for their first and last names, and then a list of their classes and room numbers.

The loop should stop when they enter STOP for their next class.

Print the schedule in the same format as the example below. Remember to use the tab escape character to make it nicely formatted.
Write the definition of a class Counter containing:
An instance variable named counter of type int.
A constructor that takes one int argument and assigns its value to counter
A method named increment that adds one to counter. It does not take parameters or return a value.
A method named decrement that subtracts one from counter. It also does not take parameters or return a value.
A method named get_value that returns the value of the instance variable counter.
Count the number of lines in the file, then generate a random knock-knock joke from the file.

Sample Run

Knock-Knock
Who's there?
Rabbit

Rabbit
who?
Rabbit up carefully it's a present!
LATEST TUTORIALS
APPROVED BY CLIENTS