0% found this document useful (0 votes)
11 views1 page

Py Week 2

The document contains three exercises aimed at teaching basic programming concepts. Exercise 1 checks if a number is prime, Exercise 2 prints the Fibonacci series up to a given number, and Exercise 3 calculates the factorial of an integer. Each exercise includes its aim, program code, and expected output.

Uploaded by

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

Py Week 2

The document contains three exercises aimed at teaching basic programming concepts. Exercise 1 checks if a number is prime, Exercise 2 prints the Fibonacci series up to a given number, and Exercise 3 calculates the factorial of an integer. Each exercise includes its aim, program code, and expected output.

Uploaded by

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

EXERCISE-1

AIM: Write a program for cheacking whether the given number is a prime number or
not
PROGRAM:
num=int(input("enter a value:"))
flag=False
if num>1:
for i in range(2,num):
if(num%i)==0:
flag=True
break
if flag:
print(num,"is not aprime num")
else:
print(num,"is a prime num")
OUTPUT:
EXERCISE-2
AIM: Write a propgram to print fibonacci series upto given n value
PROGRAM:
n=int(input("enter a value:"))
f1=0
f2=1
print(f1,f2,end=' ')
f3=f1+f2
while(f3<=n):
print(f3,end=' ')
f1=f2
f2=f3
f3=f1+f3
OUTPUT:
EXERCISE-3
AIM:write a program to calculate factorial of given integer number
PROGRAM:
n=int(input("enter a value :"))
fact=1
for i in range (1,n+1):
fact=fact*i
print("the factorial of",n,"is",fact)
OUTPUT:

You might also like