0% found this document useful (0 votes)
4 views

Practical No 01 Python

Pwp practical 1

Uploaded by

Rohan Gund
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Practical No 01 Python

Pwp practical 1

Uploaded by

Rohan Gund
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Roll No.

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

c) Aim: Conditional Statement : In a company an employee is paid as under: If his


basic salary is less than Rs. 1500, then HRA = 10% of basic salary and DA =
90% of basic salary. If his salary is either equal to or above Rs. 1500, then
HRA = Rs. 500 and DA = 98% of basic salary. If the employee's salary is
input through the keyboard, write a program to find his gross salary.
Code:
basic_salary=int(input("Enter the basic salary of an empoly:-"))
if basic_salary<1500:
hra=basic_salary*0.1
da=basic_salary*0.90
else:
hra=basic_salary+500
da=basic_salary*0.98
gross_salary=hra+da+basic_salary
print("The basic salary of an empoly is",gross_salary)
Output:

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:

e) Aim: Write a program to generate the Fibonacci series.


Code:
num=int(input("Enter any number:-"))
n1,n2=0,1
sum=0
if num<0:
print('please enter number greater than 0')
else:
for i in range(0,num):
print(sum,end=" ")
n1=n2
n2=sum
sum=n1+n2
Output:

f) AIM:- Write a python program to generate the various patterns.


i) Triangle.
Code:
num=int(input("Enter the Number for Triangle:-"))
for i in range(num):
for j in range(num):
Roll No. 2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A
print('*',end=' ')
print()
Output:

ii) Increasing Triangle.


Code:
num=int(input("Enter the Number:-"))
for i in range(num):
for j in range(i+1):
print('*', end=' ')
print()
Output:

iii) Decreasing Triangle.


Code:
num=int(input("Enter the number:-"))
for i in range (num):
Roll No. 2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A
for j in range (i,num):
print('*', end=' ')
print()
Output:

iv) Right Sided 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+1):
print('*', end=' ')
print()
Output:
Roll No. 2170
Name: Vishal Chaurasiya
Class: F.Y.BSC.IT
Div: A

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:

You might also like