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

Describe the difference between a chained conditional and a nested conditional. Give your own example of each. 


1. 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.



Suppose there is a dictionary named exam_marks as given below.

exam_marks = {'Cierra Vega': 175, 'Alden Cantrell': 200, 'Kierra Gentry': 165, 'Pierre Cox': 190}

Write a Python program that takes an input from the user and creates a new dictionary with only those elements from 'exam_marks' whose keys have values higher than the user input (inclusive).

===================================================================

Sample Input 1:

170

Sample Output 1:

{'Cierra Vega': 175, 'Alden Cantrell': 200, 'Pierre Cox': 190}



Assume, you have been given a tuple with details about books that won the Good Reads Choice Awards.

book_info = (

("Best Mystery & Thriller","The Silent Patient",68821),

("Best Horror","The Institute",75717),

("Best History & Biography","The five",31783 ),

("Best Fiction","The Testaments",98291)

)

Write a Python program that prints the award category, the book name, and its total votes earned as shown below.


Output:

The Silent Patient won the 'Best Mystery & Thriller' category with 68821 votes

The Institute won the 'Best Horror' category with 75717 votes

The five won the 'Best History & Biography' category with 31783 votes

The Testaments won the 'Best Fiction' category with 98291 votes

===================================================================


The __________ keyword is used to create a function.


  1. Input four float numbers; they could be positive or negative.
  2. Only add all inputted negative numbers, and print its sum, up to 2 decimal place.

In a company an employee is paid as under: If his basic salary is less than 30,000, then HRA= 10% of his basic salary and DA = 90% of his basic salary. If his salary is either equal or above Rs 30, 000, then HRA=500, and DA = 98% of basic Salary. If the employee's salary is input through the keyboard , Write a program to find the gross salary.

A line containing a string seperated by a comma.





Python, is, fun

Create a python code of this output

Choices:

a. Calculator

b. Odd or Even

c. Positive or Negative Number

Enter your choice: c

Enter a number: -6

-6 is a negative number.


Create a python code about this

Choices:

a. Calculator

b. Odd or Even

c. Positive or Negative Number Enter your choice: b Enter a number: 80 80 is an even number.


LATEST TUTORIALS
APPROVED BY CLIENTS