Practical No 01 Python
Practical No 01 Python
2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A
Practical No. 01
a) Aim: Create a program that asks the user to enter their name and their age.
Print
out a message addressed to them that tells them the year that they will turn
100
years old.
Code:
name=str(input("Enter the name:-"))
current_age=int(input("Enter the current age:-"))
calculate=2023+(100-current_age)
print(name,"Will become 100 year old in the age of",calculate)
Output:
b) Aim: Enter the number from the user and depending on whether the number
is
even or odd, print out an appropriate message to the user.
Code:
number=int(input("Enter the number:-"))
answer=number%2
if answer>0:
print("The given number is odd")
else:
print("The given number is even")
Output:
Roll No. 2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A
d) Aim: Write a python program to check whether the given number is positive
or
negative number.
Code:
number=int(input("Enter the number:-"))
if number>0:
print("The given number is Postive")
Roll No. 2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A
else:
print("The given number is an Negative")
Output:
v) Hill Triangle.
Code:
num=int(input("Enter the Number:-"))
for i in range(num):
for j in range(i,num):
print(' ',end=' ')
for j in range(i):
print('*',end=' ')
for j in range(i+1):
print('*',end=' ')
print()
Output: