Lesson 8.1 - Python Input, Output and Import-1
Lesson 8.1 - Python Input, Output and Import-1
Empowerment Technologies
SY 2021 – 2022
Introduction
Good day students! How are you? I
hope you are doing good. Today we will add
a new topic to your learnings about Python.
We are going to discuss today about input,
output and import in Python, which will help
you to improve your creation of a more
interactive program.
Learning Objectives
After studying and completing this module with 80% to 100% mastery of the topic and get at
least 8 correct answers to the learning activity and you are also expected to:
1. Understand the use of input, output, and import in creating a program.
2. Create a program using input and output function.
3. Display appreciation in learning the function of input and output in creating a program.
4 Pics 1 Word
Direction: Guess the specific word the fits with the theme of the images presented.
1. ______________________________
2. _______________________________
Page 1 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
3. _______________________________
Python provides numerous built-in functions that are readily available to us at the Python prompt.
Some of the functions like input () and print () are widely used for standard input and output
operations.
The simplest way to produce output is using the print () function where you can pass zero or
more expressions separated by commas. This function converts the expressions you pass into
a string before writing to the screen.
Space can be added between the string and the value of the variable by default, but this can
be change.
Page 2 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
OUTPUT FORMATTING
Here, the curly braces {} are used as placeholders. We can specify the order in which they
are printed by using numbers (tuple index).
Page 3 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
➢ Python Input
The value of variables was defined or hard coded into the source code. To allow
flexibility, we need to take the input from the user. In Python, we have the input
() function to allow this. input () : This function first takes the input from the user and
then evaluates the expression, which means Python automatically identifies whether user
entered a string or a number or list.
➢ Python Import
A module is a file containing Python definitions and statements. Python modules have
a filename and end with the extension (.py). Definitions inside a module can be
imported to another module or the interactive interpreter in Python. We use
the import keyword to do this.
Example: Created a Module named as constant.py, then import it in the new module
named as main.py.
Page 4 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
OUTPUT:
We can also import some specific attributes and functions only, using the from keyword.
Example:
OUTPUT:
Page 5 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
Key Concepts
Python Output - The simplest way to produce output is using the print () function where
you can pass zero or more expressions separated by commas.
The actual syntax of the print () function is:
Python Input - This function first takes the input from the user and then evaluates the
expression, which means Python automatically identifies whether user entered a string or a
number or list.
The syntax for input () is:
Python Import - Definitions inside a module can be imported to another module or the
interactive interpreter in Python. We use the import keyword to do this.
Page 6 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
Learning Activity
Create a simple program with the same output below, where you can input your personal
information and will display a welcome note below the information.
Study Questions/Forum:
1. What is the use of input, output and import in creating a program in Python?
2. What is the difference between the functions input and output?
Tutorial Videos
Here are some YouTube videos that can help you to with this topic.
References
• Book:
o Python Notes for Professionals – Free Python Programming Book (goalkicker.com)
o A Practical Introduction to Python Programming - Brian Heinold
Department of Mathematics and Computer Science Mount St. Mary’s University
Page 7 of 8
Science, Technology, Engineering and Mathematics
Empowerment Technologies
SY 2021 – 2022
• Online Sources
o https://www.w3schools.com/python/python_intro.asp
o https://www.programiz.com/python-programming/first-program
o https://www.geeksforgeeks.org/python-language-introduction/
o https://www.educba.com/python-literals/
o https://www.codespeedy.com/literals-in-python-with-examples/
Enrichment Activity
Create a registration form like program which can be used to input your information when creating
a social media account.
Page 8 of 8