input

How to accept the integer and float values in same input variable in python?

How to accept the integer and float values in same input variable in python? Question: How to Accept the integer and float values in the same input variable in python def interest_rate(): while True: interest_rate = input("Enter the annual interest rates: ") if interest_rate.isdigit() == True: interest_rate = int(interest_rate) if interest_rate >= 0: break else: …

Total answers: 1

How do I use an input to print a class definition?

How do I use an input to print a class definition? Question: I am trying to code something basic in python just for fun and I encountered an issue, # Employee is a class with the initialization being self, name, status e1 = Employee("Tom, Lincoln", "Present") e2 = Employee("Sam, Bradley", "Absent") print(e1.status) # printing e1 …

Total answers: 2

Validating given input and printing every prime number =< given input. (Python)

Validating given input and printing every prime number =< given input. (Python) Question: So I have read tons of solutions to this type of questions, but they all seem to be way too complicated, or I can’t find any useful solutions in them. I have written the first part where I have to ask for …

Total answers: 2

How can I fix a bug using modulo (%) in Python?

How can I fix a bug using modulo (%) in Python? Question: I am making a converting program in Python, and in this case it’s from feet to yards. I have having trouble with a specific line of code that is not showing an error message, yet refuses to actually work. When I run the …

Total answers: 3

Python input() function is skipping a line on the first input

Python input() function is skipping a line on the first input Question: I’am trying to make a text-adventure but i encountered a weird problem that I can’t solve. I dont know what I’ve changed because I know it worked at some point but the startinput doesn’t take the first user input and skipps to the …

Total answers: 2

I am trying to allow the user input to select specified options from a list

I am trying to allow the user input to select specified options from a list Question: I have only been learning Python for about two weeks and need a bit of help with an assignment. Below is the code I have written so far, import random colour_list = ["red","blue","white","yellow","pink","orange","black","green","grey","purple"] start_num = int(input("enter a starting number …

Total answers: 1

Check if the input is integer float or string in python

Check if the input is integer float or string in python Question: I am a beginner in python and I am currently working on a calculator not like this: Enter Something: add "Enter 1 number : 1" "Enter 2 number : 3" The answer is 5 not like that or using eval() I Want to …

Total answers: 2

ValueError: could not convert string to float: '8/3'

ValueError: could not convert string to float: '8/3' Question: I am having the folllowing instruction x1,y1,x2,y2,x3,y3,xp,yp = map(float, input().split()) When I am trying to execute it for a fractional value, e.g. 8/3, I get an error message. x1,y1,x2,y2,x3,y3,xp,yp = map(float, input().split()) 0.1 0.2 -8 -16.67 0 0.1 8/3 1 # output Traceback (most recent call …

Total answers: 2