

input & output function
Presentation
•
Instructional Technology
•
10th Grade
•
Practice Problem
•
Medium
s tobgyal
Used 28+ 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
19 questions
Le futur simple - intro
Presentation
•
10th Grade
20 questions
Commas with dep and ind clauses
Presentation
•
10th Grade
21 questions
Best Method: Solving Systems of Equations
Presentation
•
7th - 10th Grade
21 questions
Cinco De Mayo
Presentation
•
10th Grade
21 questions
Introduction to Trigonometry
Presentation
•
10th Grade
21 questions
Cold War Intro
Presentation
•
KG
19 questions
INDUS RIVER VALLEY CIVILIZATION
Presentation
•
10th Grade
19 questions
CORRELATIVE CONJUNCTION
Presentation
•
10th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade