1.2.1
Input & Output
Test your knowledge with free interactive questions on Seneca — used by over 10 million students.
Input
There must be some mechanism for the user to input data to the computer.

What data can I input?
- Data can be input from any device connected to the computer.
- The keyboard is the most common data input device for command line programs.
- We will only look at keyboard input in this course.

The input function
- Python has a built in function (command) which allows us to take keyboard input.
- We can use the code: input(“Prompt”) to take the input.
- We can write any text for the “Prompt”, which will be displayed to the user before they type their response.
- A prompt is a message that is displayed to the user before they type their response.

Data type of input
- When data is entered from the keyboard, it is automatically a ‘string’.
- A string is a sequence of character inputs from the keyboard, for example ‘Hello’.
Output
Output is necessary so that we can see the results of programs.

Why do we need outputs?
- Outputs are important so that we can communicate the result of a program to the user.
- Outputs are usually delivered as text onto the screen.

The print function
- The output function in Python is called ‘print’.
- The output function ‘prints’ data onto the screen.
- E.g. print(“Hello, world!”) would output the text “Hello, World!”.

What data can be outputted?
- Output data must be a string before we can print it.
- If we want to display data that is not a string, then we must first cast it to a string.
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Practice questions on Input & Output
Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.
- 1
- 2What data type is keyboard input?Multiple choice
- 3Data can only be input from a keyboard. True or false?Multiple choice
- 4How are outputs usually delivered in a command line program?Multiple choice
- 5Why are output statements used?Multiple choice
Unlock your full potential with Seneca Premium
Unlimited access to 10,000+ open-ended exam questions
Mini-mock exams based on your study history
Unlock 800+ premium courses & e-books