user-input

Can't get raw_input to return a number

醉酒当歌 提交于 2019-12-02 11:25:37
print "How old are you?", age = raw_input() print "How tall are you in inches?", height = raw_input() print "How much do you weigh in pounds", weight = raw_input() print "So, you are %r years old, %r inches tall, and %d kilograms." % ( age, height, weight / 2.2) So I am new to code and this is my code. When I use terminal to compile it, I get this: How old are you? 1 How tall are you in inches? 1 How much do you weigh in pounds 1 Traceback (most recent call last): File "ex11.py", line 9, in <module> age, height, weight / 2.2) TypeError: unsupported operand type(s) for /: 'str' and 'float' Can

scanf issue when reading double

前提是你 提交于 2019-12-02 11:01:15
问题 I'm using MinGW on windows 7 to compile C files. My problem is a strange behaviour with scanf() to read double s from user input. My code: int main() { double radius = 0; double pi = 3.14159; scanf("%lf \n", &radius); // after the input, it continues waiting... radius = ((radius * radius) * pi); printf("A=%.4lf\n", radius); return 0; } When I run this program it's necessary input a value, let's suppose 100.64 , the normal behaviour is press enter and the program should continue and show the

Buttons to be renamed by the user

左心房为你撑大大i 提交于 2019-12-02 10:51:34
问题 I am having problems coding some of my buttons. This is what I've got so far: Public Class Form1 Dim Button(12) As Button Dim X As Integer Private Sub EventName() Dim message, title, defaultValue As String Dim myValue As Object If Label4.Text = "Admin" Then ' Set prompt. Message = "Enter Product Name" ' Set title. title = "Product Name" defaultValue = "" ' Set default value. 'Display message, title, and default value. myValue = InputBox(Message, title, defaultValue) Button(X).Text = myValue

User Restrictions based on Field Content in MS Access

↘锁芯ラ 提交于 2019-12-02 07:52:44
I need to set up user permissions within the same table, based on the value of a field. I know that this is not directly possible in Access but a post on Allenbrown.com points to a way of doing this see here . I'm not proficient in coding so I'm hoping that I can get some directions from you. Here are the details: I have two tables in the database, a parent one populated via a form and a children one populated via a subform. The parent contains companies and the child contain subsidiaries of those companies. In the child table, I have a field called "Domicile" and I want to discriminate user

How to print the user input on screen from a TextField using Java Swing

社会主义新天地 提交于 2019-12-02 07:00:20
问题 I am new with GUI in Java. However, I tried the program below but it won't work. It's a standalone application. I searched the web but couldn't find relevant answer. Please help. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class usernamepass extends JFrame implements ActionListener{ JTextField a; public usernamepass(){ JFrame jp=new JFrame(); add(jp); a=new JTextField(12); jp.add(a); a.addActionListener(this); } public void actionPerformed(ActionEvent ae){ this

Python user input in child process

雨燕双飞 提交于 2019-12-02 05:40:51
问题 I'm trying to create a child process that can take input through raw_input() or input(), but I'm getting an end of liner error EOFError: EOF when asking for input. I'm doing this to experiment with multiprocessing in python, and I remember this easily working in C. Is there a workaround without using pipes or queues from the main process to it's child ? I'd really like the child to deal with user input. def child(): print 'test' message = raw_input() #this is where this process fails print

scanf issue when reading double

让人想犯罪 __ 提交于 2019-12-02 05:38:41
I'm using MinGW on windows 7 to compile C files. My problem is a strange behaviour with scanf() to read double s from user input. My code: int main() { double radius = 0; double pi = 3.14159; scanf("%lf \n", &radius); // after the input, it continues waiting... radius = ((radius * radius) * pi); printf("A=%.4lf\n", radius); return 0; } When I run this program it's necessary input a value, let's suppose 100.64 , the normal behaviour is press enter and the program should continue and show the result, but the program stays waiting for more input. If I type 0 and press enter again, the program

user input to create object

一世执手 提交于 2019-12-02 05:28:48
I'm trying to create a new object using a user input. I tried assigning the user input to variables but don't know how to add the variables to the new object in the when I declare the new object. This is just the part of my code that i need help with. part i need help with is line 8. i know i can just put something random and when i use my set methods it will overwrite but that's not what I want. thank you in advance Scanner input = new Scanner(System.in); System.out.println("Enter the name of the Soda: "); String soda = input.nextLine(); System.out.println("Inventory count?: "); int product =

Java - Assigning User Input to Variable / Change Counter

核能气质少年 提交于 2019-12-02 04:57:35
I'm quite new to java, although I have a fairly basic knowledge of C++. For my assignment I am counting change and sorting it into American currency (i.e., if you had 105 cents, it would divide it into one dollar and one dime). Logically I understand how to do this, but I'm having some serious trouble understanding the java syntax. I'm having serious trouble to find a way to assign a user-inputted value to a variable of my creation. In C++ you would simply use cin, but Java seems to be a lot more complicated in this regard. Here is my code so far: package coinCounter; import KeyboardPackage

Numeric comparison with user input always produces “not equal” result

眉间皱痕 提交于 2019-12-02 04:46:24
I want to get a number input by the user via input() and compare it with a specific value, i.e., 3 . However, I have the impression my if statement doesn't work. The comparison is always False . Start = input() if Start == 3: print ("successful") Python 3 input function returns string. Try like this start = input("-->: ") if start == "3": print("successful") moooeeeep Some things you could do on your own to get to the root of the problem: Ways to get to know the type of the object: print(type(start)) # prints <class 'str'> print(repr(start)) # prints '3' Unlike Python 2.x, the function input()