

input & output function
Presentation
•
Instructional Technology
•
10th Grade
•
Practice Problem
•
Medium
s tobgyal
Used 23+ times
FREE Resource
20 Slides • 6 Questions
1
input function, output function & Comments
By s tobgyal
2
"Every leaf fall is not the end, but it is the beginning"
3
input() function:
is used to take input from the user during program execution.
Whatever the user types using input() is always stored as a string (text), even if it looks like a number or other data type.
variable = input("Message for the user")
4
1. User Interaction
It lets users enter data while the program is running.
2. Dynamic Programs
Makes programs flexible and responsive to user input.
3. Real-World Use
Useful in applications like forms, games, quizzes, and data entry.
4. Takes Custom Input
Allows users to provide their own values instead of hardcoded ones.
5. Improves Usability
Makes programs more engaging and user-friendly.
Importance of input() Function in Python
5
Demonstration.....
6
Write a Python program that asks the user to enter the following information:
Full name
Age
Grade
Favourite subject
Then, display the information in a clean format.
7
Write a python program asks the users to enter their name and then displays the name on the screen.
Write a Python program to ask the user to enter the marks of following subjects and display it accordingly:
English
Dzongkha
Maths
Science
HCG
ICT
Economics
Activities:
8
9
Multiple Choice
What does the input() function do in Python?
A) It displays a message on the screen
B) It reads a line from standard input as a string
C) It executes a Python script
D) It pauses the program for a given time
10
Multiple Choice
How can you convert input from the user into an integer?
A) int(input("Enter number: "))
B) input(int("Enter number: "))
C) str(input("Enter number: "))
D) input("Enter number: int")
11
Multiple Choice
Which of the following statements is true about the input() function?
A) It can directly accept numeric input
B) It returns data in boolean format
C) It always returns data as a string
D) It reads multiple lines of input by default
12
OUTPUT:
Output refers to the information or result produced by a computer after:
Taking input
Processing the input
(Optionally) Storing the data
Displaying or presenting the result
13
print() Function in Python
is used to display messages, variables, or results on the screen.
Syntax:
print(object(s), sep=' ', end='\n')
object(s): Text, numbers, variables, etc.
sep: Separator (default is space)
end: What to print at the end (default is newline \n)
14
print string:
print("Welcome to python programming")
#output: Welcome to Python! programming
using variable(s):
greet="Welcome to python programming"
print(greet)
#output: Welcome to python programming
15
Output Formatting in Python
means making your printed output look clean, aligned, or styled in a specific way.
Common Methods of Output Formatting:
1. Using commas in print(,)
2. String Concatenation (+)
3. Using f-strings
4. Using .format()
16
1. Using commas in print()
print multiple objects on the same line using the print() function by separating the objects with commas. Automatically adds spaces between items.
Example:
print("I","Love","Bhutan")
#output: I Love Bhutan
17
2. String Concatenation (+)
joining two or more strings together into one string. Joins strings together (only works with strings).
Example:
print("Hello"+"Karma")
#output: HelloKarma
name="Wangpo"
age=15
print(name+age)# cannot add because of different types
# instead use comma to join
18
3. Using f-strings:
Just add an f before the string, and put variables or expressions inside {}. Easiest and most modern way (Python 3.6+).
Example:
name="Wangpo"
age=15
print(f'My name is {name} and i am {age} years old')
19
4. Using .format()
an older but still useful way to insert values into strings before f-strings were introduced. The {} are placeholders, and .format() fills them in order.
Example:
name="Wangpo"
age=15
print('My name is {} and i am {} years old'.format(name,age))
20
Python comment(s):
Are used to explain what the code does or leave notes for yourself or others. Used to make code easier to understand
Two types of comments:
1. Single line comments
#Comments here...bla bla
2. Multiline comments
'''this is more
than one line
comment
'''
21
Benefits of Using Comments in Code
1. Improves Readability
Comments help explain what the code does, making it easier to understand.
2. Eases Code Maintenance
Makes it easier to update or modify code later.
3. Helps Debugging
Helps identify what each part of the code is supposed to do.
4. Supports Teamwork
Other programmers can quickly understand your logic.
5. Saves Time
Saves time for you and others when revisiting the code after a while.
22
23
Multiple Choice
What is the purpose of comments in Python code?
A) To make the program run faster
B) To describe code and make it easier to understand
C) To execute hidden instructions
D) To store data
24
Multiple Choice
What happens to the comment when the Python program runs?
A) It gets stored in memory
B) It is ignored by the interpreter
C) It produces an output
D) It causes a syntax error
25
Multiple Choice
Which of the following is used to display output in Python?
A) output()
B) echo()
C) print()
D) display()
26
input function, output function & Comments
By s tobgyal
Show answer
Auto Play
Slide 1 / 26
SLIDE
Similar Resources on Wayground
20 questions
Narrative Text
Lesson
•
10th Grade
20 questions
Trig Ratios Review
Lesson
•
10th Grade
21 questions
question tags
Lesson
•
10th Grade
21 questions
Isosceles Triangle Theorems
Lesson
•
10th Grade
21 questions
Intro to mole
Lesson
•
10th Grade
19 questions
Line and Rotational Symmetry
Lesson
•
10th Grade
18 questions
Multimedia
Lesson
•
9th - 10th Grade
20 questions
Relative clauses
Lesson
•
10th Grade
Popular Resources on Wayground
10 questions
5.P.1.3 Distance/Time Graphs
Quiz
•
5th Grade
10 questions
Fire Drill
Quiz
•
2nd - 5th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
15 questions
Hargrett House Quiz: Community & Service
Quiz
•
5th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for Instructional Technology
12 questions
Digital Ethics Challenge
Quiz
•
10th Grade
10 questions
Cell Organelles and Their Functions
Interactive video
•
6th - 10th Grade
10 questions
Exploring Basic Probability Concepts
Interactive video
•
6th - 10th Grade
32 questions
College Trivia
Quiz
•
9th - 12th Grade
18 questions
Informative or Argumentative essay
Quiz
•
5th Grade - University
20 questions
Women History Month
Quiz
•
6th - 12th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
20 questions
Career
Quiz
•
9th - 12th Grade