Lesson3
Input and
Int
Functions
Objectives:
● Write and execute Python programs Input and Int
functions.
First steps in Python:
• Open the website:
https://python.qubitscs.com/
Input Function:
The python input
function is used to
ask the user for
information.
Step1: Use the input function and
type your msg.
Step2: Add your input to a
variable
Step3: Display the Variable
Revision:
• Enter two input functions:
1. Intput1: “Enter your name”
2. Input2: “How old are you?”
• Display your output as:
Ex: “Ali is 12 years old”
Revision : Answer
Warm up:
• Enter two input functions:
1. Intput1: “Enter first number” Ex: 2
2. Input2: “Enter second number” Ex:3
• Display your output as:
• Ex:
1. The sum is" , 5
2. The product is" , 6
Warm up : Answer
Activity2: Answer with Error! XD
Solution: int() function
• The int() python is used to convert the
specified string or number into an integer
value.
Solution: int() function
Activity 1
• Write a program that takes a user's age as input,
converts it to an integer, doubles it, and prints the
result.
• Input: "Enter your age: 10"
• Output: "Your age doubled is 20."
Activity 2
• Write a program that takes two numbers as input,
converts them to integers, calculates the sum and
average, and prints the results.
• Input: "Enter the first number: 5"
• Input: "Enter the second number: 15"
• Output: "The sum is 20, and the average is 10."
Activity 3
• Write a program that takes the length and width of a
rectangle as input, converts them to integers, calculates
the area and perimeter and prints the result.
• Input: "Enter the length of the rectangle: 7"
• Input: "Enter the width of the rectangle: 4"
• Output: "The area of the rectangle is 28.“
• Output: "The perimeter of the rectangle is 22."