How do you ask a question on python?
Show
1. Asking QuestionsInput means to enter data into a program. Use the input command to ask a question. You must save the answer into a suitably named variable using the = symbol. Task 1 - Create a new Python program and save the file as 3-Inputs.py Use the picture to help you ask what someone's name is. Run the program and type your name. When you run the program (F5) you can type your answer on any question line in the Python Shell. 2. Asking more QuestionsThere is no limit to how many questions you can ask in Python. It is the most important way to interact with the user of your program. Task 2 - Ask two more questions on topics of your choice. 3. Using Variables in a SentenceWhen we have printed the answers so far, they have not been very informative! You can print variables together with sentences so that they mean more. Use a comma ( , ) between variables and sentences. Task 3 - Use the pictures to help you add commas and sentences to your program to be more informative. BONUS: After I took the screenshot of my code I added in print lines in the two blanks spaces that print a line of dashes. Try to do the same to make your program easier to read. 4. Using IntegersAn integer is a whole number. When you are asking a question that you know will have a number for an answer, you need to add int( before your input. Don't forget to add double close brackets at the end of the question line! Task 4 - Underneath your previous questions (don't delete anything) ask 2 questions that will have numbers for answers. You must use int( - see the image for help. Challenge ProgramsUse everything that you have learned on this page to help you create these programs... Challenge Task 1 - Funny Food
When you run it, it could look something like this: Challenge Task 2 - Trivia Question
When you run it, it could look something like this: Challenge Task 3 - Getting to School
When you run it, it could look something like this: <<< #2 Variables#4 Calculations >>>How do you ask something in Python?To ask for user input in Python, use the built-in input() function. In addition to asking for simple string input like this, you also want to learn how to: Ask for multiple inputs in one go. Ask for input again until a valid input is given.
Where do I ask questions in Python?The most efficient way of getting help is via the various mailing lists and newsgroups, particularly the comp. lang. python newsgroup. Also, you can ask your questions in the inofficial Python Wiki.
How do you ask yes or no questions in Python?answer = input("Enter yes or no: ") if answer == "yes": # Do this. elif answer == "no": # Do that. else: print("Please enter yes or no.")
How do you ask random questions in Python?how to make a random question generator in python. num1 = random. randint(1, 10) . num2 = random. randint(1, 10) . answer = int(input(f"What is {num1} + {num2}?\n")) . if answer == (num1 + num2): print("Correct"). |