How do you ask a question on python?

1. Asking Questions

Input 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.

How do you ask a question on python?

How do you ask a question on python?

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 Questions

There 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.

How do you ask a question on python?

3. Using Variables in a Sentence

When 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.

How do you ask a question on python?

How do you ask a question on python?

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 Integers

An 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.

How do you ask a question on python?

How do you ask a question on python?

Challenge Programs

Use everything that you have learned on this page to help you create these programs...

Challenge Task 1 - Funny Food

  1. Create a new Python program. Save it as '3-FunnyFood.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks two questions, one for their favourite colour and one for their favourite food.

  4. Print a funny sentence using both of their answers.

  • BONUS: Try to use only one print line.

  • Remember: Break up variables in a print line by using commas.

When you run it, it could look something like this:

Challenge Task 2 - Trivia Question

  1. Create a new Python program. Save is as '3-Trivia.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks the user a trivia question of your choice.

  4. Print the correct answer AND their answer.

  • BONUS: Use only one print line.

  • BONUS: Try to use only two lines in total.

    Remember: Break up variables in a print line by using commas.

When you run it, it could look something like this:

How do you ask a question on python?

How do you ask a question on python?

Challenge Task 3 - Getting to School

  1. Create a new Python program. Save it as '3-School.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks two questions, one for how they get to school and one for how long it takes. Don't forget - use int( and then double close brackets for a number!

  4. Print an appropriate response that uses both of their answers.

  • BONUS: Use two separate input lines.

  • BONUS: Try to use only one print line.

    Remember: Break up variables in a print line by using commas.

When you run it, it could look something like this:

How do you ask a question on python?

<<< #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").