by CodeChum Admin
Functions that return the value of a base and an exponent is very common so I want to switch it up.
This time, we’re going to try to reverse-engineer these functions and find out the exponent of a certain number based on the value of the result and the base used to get that value.
Instructions:
Input
1. The base
2. The result
Output
Enter·the·base:·2
Enter·the·result:·8
Exponent·=·3
by CodeChum Admin
I love facts. In fact, I dream a lot about facts. Ever since I was a kid, all I ever think of are facts. And that's a fact!
I don't know if that made any sense to you but I think you know about factorials, hmm? In Mathematics, a factorial of a number is the product of all the numbers from 1 up to that number. There is one exception though and that is the factorial of 0 which is 1.
Instructions:
Input
1. Integer to be processed
Output
Enter·n:·3
Factorial·of·3·is·6
by CodeChum Admin
This one’s probably one of the most popular recursion problems in programming. Your task is to create a recursive function that prints out the the first up to the nth number in the Fibonacci sequence by going through the numbers using recursion.
In case you forgot, here is the definition of a Fibonacci sequence:
Instructions:
Input
1. Elements to be printed
Output
Enter·n:·4
1·1·2·3
by CodeChum Admin
A mitosis program has gone out of hand and now does abnormal cell duplication. Rather than scrapping the project, the researchers decided to observe and predict the cell duplication using a program.
Instructions:
Input
1. Base integer
2. Initial factor
3. Number of times to process
Output
Enter·base·integer:·3
Enter·initial·factor:·2
Enter·number·of·times·to·process:·3
Result·=·54
by CodeChum Admin
In order to preserve Spiderman's last words, Mr. Stark wants us to create a program that takes a string and output the string with each proceeding output having one less character until it outputs only one string.
Instructions:
Input
1. String to be processed
Output
Enter·string:·Hello!
Hello!
Hello
Hell
Hel
He
H
by CodeChum Admin
In life, good things take time.
Let's make a simple program that mirrors this beautiful idea where we ask the user for two integer inputs. The first one would represent the starting number and the second one would represent the next n integers after it.
For example, if the first number inputted is 2 and the second number inputted is 3, then the output would be 3, 4, 5 because these are the next 3 integers after 2.
Instructions:
Input
1. Starting integer
2. Number of integers
Output
Enter·starting·integer:·2
Enter·how·many·next·integers:·3
3·4·5
Sales. Bonus rate%
Above 50001. 15
Between 25001 and 50000. 10
Between 1 and 25000. 5
Draw a flow chart for a program that prompts a user to enter the employees basic salary and sales. The program then calculates the gross salary and outputs employees basic salry, gross salary and bonus
Make an octave code to find the root of cos(x) – x * e x = 0 by using bisection method. The answer should be corrected up to four decimal places.
. Make an octave code to integrate e* with respect to dx from 0 to 1, by Simpson’s ⅓ rule. Divide the limits into 6 equal parts.
Submit your Python script file in the posting of your assignment. Your Python script should be either a .txt file or a .py file.
You must execute your script and paste the output produced into a document that you will submit along with your Python script.
It is very helpful if you print a placeholder between the printing of 9 lines and the printing of 25 lines. It will make your output easier to read for your peer assessors. A placeholder can be output such as “Printing nine lines” or “Calling clearScreen()”.
The following items will be used in the grading rubric for this assignment. Make sure that you have addressed each item in your assignment.
Does the assignment implement new_line, three_lines, nine_lines, and clear_screen functions, as well as a main section of the program which calls the functions?