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.
Happy Numbers: A number is called a happy number, if you start with the given number
and arrive at 1 by repeating the following process (as illustrated in the below example):
(a) compute the sum of the squares of given number digits
(b) if the resultant value is 1, then the number is happy number, else execute point (a) for
the newly produced number.
Note that if a number is not a happy number, there will be an endless loop to this execution.
Goal: In this question, you are required to write a recursive function that checks whether
the number entered by the user is a happy number or not for 10 cycles/iterations only. The
output shown in blue colour should be shown by the function and text in yellow colour
should be displayed by the main function.
Write a C++ program in which write a function convert() that converts a decimal number to a binary, octal, and
hexadecimal equivalents. The function will take two arguments: first argument will be
the number to be converted and second argument will be the base in which this number
is to be converted. Function should return the converted value. You may use strings to
represent converted numbers like “0x3A”, “00101100”, “72” etc.
b. Call convert() function in the main program to produce the following output. It is same
as you made in the previous assignment.
Example output:
Enter upper limit = 20
Enter lower limit = 30
Please enter a value of lower limit between 0 and the upper limit and try again.
Enter lower limit again = 10
............................................................................
Decimal Binary Octal Hexadecimal
Wite a C++ function. A college offers a course that prepares students for the state licensing exam for real estate brokers.
Last year, ten of the students who completed this course took the exam. The college wants to know
how well its students did on the exam. You have been asked to write a program to summarize the
results. You have been given a list of these 10 students. Next to each name is written a 1 if the
student passed the exam or a 2 if the student failed.
Your program should analyze the results of the exam as follows:
Input each test result (i.e., a 1 or a 2). Display the prompting message "Enter result" each time the
program requests another test result.
Count the number of test results of each type.
Display a summary of the test results indicating the number of students who passed and the
number who failed.
If more than eight students passed the exam, print the message "Raise tuition."
Write a java program to work like a calculator. The calculator should include +, -, *, / and %. The
calculator should not stop working unless the user asks it to exit. You should use Switch case
Write a program to overload operators in the same program by writing suitable operator member functions for following set of expressions: O5= (O1/O2) *(O3+O4) [Here O1,O2,O3,O4 and O5 are objects of a class “overloading”, and this class is having one integer data member]
If the monthly home loan repayment is more than a third of the user’s gross monthly
income, the software shall alert the user that approval of the home loan is unlikely.
7. The software shall calculate the available monthly money after all the specified deductions
have been made.
8. The software shall not persist the user data between runs. The data shall only be stored in
memory while the software is running.
Non-functional requirements:
1. You are required to use internationally acceptable coding standards. Include
comprehensive comments explaining variable names, methods, and the logic of
programming code.
2. You are required to use classes and inheritance. Create an abstract class Expense, from
which HomeLoan, etc., can be derived.
3. Store the expenses in an array
Create a c++ class entertainment consisting of the following data members:
• Title
• Air_Date i.e. Release Date
• Genre
• Type (i.e. Movie, TV Show)
• Runtime
• Country
• Actors
• Rating.
Follow the instructions below for creating the class and objects: Store the owners name as a dynamic array data member.
• Store the genre as a dynamic array data member.
• Store the names of the actors as a dynamic array data member.
• Create an object named “obj1” and initialize the object.
• Create a copy constructor that can list of genre, country and rating.
• Generate another object named “obj2” that is created by copying only the genre, country and ratings from “obj1”.
• Initialize the remaining attributes with values of your own.
Write a program that randomly fills in 0s and 1s into a
6 X 6 matrix, prints the matrix and finds the first row and the first column with the
least 1s.
Create an account by entering username, password, first name and last name.
a. The system needs to check that the following conditions are met, and reply with the
appropriate output message.