0

I'm new but I'm not sure how inputs work what kinds of things do I put in the parentheses

4th Aug 2024, 2:05 PM
Evan Cohens
Evan Cohens - avatar
4 Respostas
+ 2
Are you talking about python? (That would be a good tag to add) I guess, if you're using another interpreter - not Sololearn's - you would put a prompt in the input parentheses for what kind of value you'd expect. If you want a name, for example, you'd put something like "what do I call you?". If you need a number, say an age, then, "how many winters have you survived?" And so on... Note: this won't really work with the Sololearn compiler/interpreter because it works in a different way to save processing and as a security. When you tap run, then the program will expect all of the required inputs right away. Afterwards, your program will run and output accordingly.
4th Aug 2024, 5:13 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Hi, Are you referring to the input() function? You don't have to include anything within the parentheses, but you may add a string as a prompt to let the user know what kind of input is expected. For example: name = input("What is your name?") The input() function signifies that you're accepting user input which will be stored in the variable you've created. When the input() function is called, it indicates that at that specific point in your code, user input is expected. So, whenever you run this code, you'll be prompted to type something, and whatever you enter will be stored as a string in the variable name. If you want to display what was entered by the user, you can then use: print(name) And whatever you typed will be displayed. https://sololearn.com/compiler-playground/cbJ5OZEnxTKJ/?ref=app
4th Aug 2024, 6:41 PM
Chris Coder
Chris Coder - avatar
0
Thank you so much it helped me a lot
4th Aug 2024, 8:03 PM
Evan Cohens
Evan Cohens - avatar
0
Without knowing the context, it is impossible to answer comprehensively, so I will give the answer in a general way. Input data for a function (method). This is the data that the method will need to work. If the method does not need data, then it is written simply (). For example, the famous print function: print("Hello, World!") It accepts a string, which it prints to the console. But we can write our own method... for example: class userPrint: def printMulti(s: str, n: int): return print(s * n) myString = "Print" userPrint.printMulti(myString, 3) I wrote a method that takes a string s and a number n, and outputs the string n times. To paraphrase, in parentheses you need to indicate the data that the method expects! (Google the method and look in the docs/examples to see what is needed in the method, if something is unclear)
5th Aug 2024, 3:31 AM
Animaliss
Animaliss - avatar