Concept explainers
I need help with my homework on python. but I have tried to do this code and it had a maroon icon pop open on the program when I ran the item.
def interest():
amt = input("Enter loan amount: ")
interest = (input("Enter interest rate: "))
int_rate = interest.replace('%','')
int_rate1 = float(int_rate)
for ik in amt:
if ik == 'k':
amt_loan = amt.translate({ord(i): None for i in '$k,'})
loan = int(amt_loan) * 1000
roi = float(int_rate1 / 100)
a = loan * (1 + roi)
total_int = a - loan
print(loan)
print(total_int)
# remove $ sign or , from the amount if any
else:
if ik == '$' or ik == ',':
amt_loan = amt.translate({ord(i): None for i in '$,'})
amt_l = int(amt_loan)
roi =float(int_rate1 / 100)
A = amt_l* (1 + roi)
total_int = A - amt_l
print("Totoal: amount:", amt_l)
print("total interest:",total_int)
ch = input("Countinue : (Y/N)")
if ch == 'Y' or 'y':
interest()
else:
print("Bye!")
interest()
But when I do it it says this Traceback (most recent call last):
File "C:/Users/module>
interest()
File "C:/Users//AppData/Local/Programs/Python/Python39/.py1.py", line 33, in interest
interest()
TypeError: 'str' object is not callable
>>>
What do I need to do to fix it onto the python program? Here is the image for my homework.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 4 images
- Hello, This is part of my hangman simulation in C++. If you compile and run it and type "Easy," the code should run. If you run it though, the body of the hangman doesn't align when you guess wrong. Could you help me with that and implement an if statement to repeat the program if user wants to play again? #include <iostream> #include <cstdlib> #include <ctime> #include <string> #include <iomanip>using namespace std; const int MAX_TRIES = 5;char answer; int letterFill(char, string, string&); int main() { string name; char letter; int num_of_wrong_guesses = 0; string word; srand(time(NULL)); // ONLY NEED THIS ONCE! // welcome the user cout << "\n\nWelcome to hangman!! Guess a fruit that comes into your mind."; // Ask user for for Easy, Average, Hard string level; cout << "\nChoose a LEVEL(E - Easy, A - Average, H - Hard):" << endl; cin >> level; // compare level if (level == "Easy") {//put all the string inside…arrow_forwardIn your programming project, you are expected to realize the game of chance called Tombala as a C ++ console application. The details of this game played in real life are listed below: Tombala is a game of chance played over 3 sets with a minimum of 2 and a maximum of 5 players. In the tombala game, each player is given a unique (different) tombala card with 15 integers on it at the start of the game. These whole numbers in question are random numbers in the range of 1 (inclusive) to 90 (inclusive). Each set of the game makes use of a bag of stamps with consecutive integers in the range of 1 (included) to 90 (included). A check is randomly drawn from this bag each time, and each player checks if the number on that checker exists on their tombala card. This process continues similarly until the game set is completed. The player with 5 numbers on his card is deemed to have made the first zinc, the player with 10 numbers drawn from the bag, the second zinc, and the…arrow_forwardUse C language to write your program. Show your code in a picture with commentsarrow_forward
- Help me homework c++ The shots file holds a list of shots (imagine some hitscan weapon in a video game like a shotgun or something). Each shot has an origin and a direction. The origin is an (x,y) coordinate, like (5,3). The direction is a slope and whether the shot is traveling along that slope or in the reverse. A slope of "Vertical" means that the shot is travellingstraight up and down. The format is:x_location y_location slope(either a number like 2.1 or a non-number meaning"Vertical") forwards(1 meaning forwards, 0 meaning backwards) 0 0 0 00 0 0 10 0 Vertical 00 0 Squirrel 110 10 -1 1-10.1 -100.01 2.1 0 The first line is a horizontal line shooting left from the origin (0,0).The second line is a shot also travelling horizontally from the origin, but forward along the x axis instead of backwards.The third line is shooting straight down out of the originThe fourth line is shooting straight up out of the origin (any non-number means Vertical, not just Vertical)The fifth line is…arrow_forwardI'm trying to create a c program that will take in a ten-digit ISBN number and then check to see if the number is valid by calculating its weighted sum. This is the code that I have up to know, but I'm not sure what to do next. Can you give me some pointers? DOCUMENTATION-------------This program will determine if an ISBN number is valid by calculating its weighted sum.********************************************************************/#include <stdio.h>#include <stdbool.h> #define ISBN_SIZE 10#define MOD_NUM 11 void printInstructions(void);void getIsbn(int isbnArray[]);void printIsbn(int isbnArray[]);int calculateWeightedSum(int isbnArray[]);bool isIsbnValid(weightedSum);void printGoodbye(void); int main(){int isbnArray[ISBN_SIZE] = {0}; printInstructions();getIsbn(isbnArray); printf("\n\nThe ISBN ");printIsbn(isbnArray); if(isIsbnValid(calculateWeightedSum(isbnArray))){printf(" is valid.");}else{printf(" is not valid.");} printGoodbye(); return 0;}…arrow_forwardUsing C++ For each game played you will write the final results for the player and the computer. The data written should look like this: 19 21 18 23 21 16 You will have the player data first, a tab '\t', and then the computer result followed by a newline '\n' So, in the example above, in the first game, the player got 19 and the computer got 21. In the second game, the player got 18 and the computer got 23. After the player stops the program, you will close the writing file stream and open the input file stream of the newly created file. Read each line of numbers and calculate: The average result of the player for all the games played. The average result of the computer for all the games played. The total wins for the player and the computer. Then, declare who is the best 21 player! The output from above will look like this assuming the computer is named, "Ruby." Your game average was 19.3 Ruby's game average was 20.0 You won 2…arrow_forward
- In python, what does the following function do? Fill out the docstring description for the function (the first line).arrow_forwardCan you write a new code in C ++ language with the values I sent you, just like this output? There are two files named group1.txt and group2.txt that contain course information and grades of each student for each class. I will calculate each course average for each group and show in simple bar graph. Use "*" and "#"characters for group1 and group2, respectively. I will see the number -999 at the end of each line in the input files. This value is used for line termination and you can use it to verify that you have arrived at the end of the line. The averages of each group should also be calculated and printed at the end of the file. All of the results will be printed to the file. There will be no screen output. Sample output is shown in Figure 1. Group 1: CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999ENG 80 90 80 94 90 74 78 63 83 80 90 -999HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999PHY 100 83 93 80 63 78 88…arrow_forwardIn Java: Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education