xxxxxxxxxx
# Any input taken by python is always taken as a string.
# To convert it to an integer, we have to wrap input() in int(). Example:
num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
total = num1 + num2
print(f'Sum: {total}')
xxxxxxxxxx
birth_year = input("enter birth year: "); //input takes birth_year as STRING
age = 2022- int(birth_year); //birth_year is converted in INT
//other built in functions used for converting: int (), float (), bool(), str()
xxxxxxxxxx
age = int(input('Enter your age: '))
print('Type of age is: ', type(age))
xxxxxxxxxx
Complete the code to take the input as an integer and output a square of "*" characters.
An input can be taken by using the following line. You will learn more about inputs in the next session.
val = int(input())
For example, if the input is 2 and 5 respectively:
For example:
Input Result
2
**
**
5
*****
*****
*****
*****
*****