0% found this document useful (0 votes)
1 views10 pages

Computer Science 1

The document contains a series of Python programs that demonstrate basic programming concepts, including finding the square root of a number, swapping variables, converting Celsius to Fahrenheit, printing the Fibonacci series, calculating factorials, printing even numbers in a range, grading based on total marks, identifying vowels and consonants, and printing the first 10 natural numbers. Each program includes user input prompts and outputs the results. The document serves as a practical guide for beginners in Python programming.

Uploaded by

sinhapiyushraj3
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)
1 views10 pages

Computer Science 1

The document contains a series of Python programs that demonstrate basic programming concepts, including finding the square root of a number, swapping variables, converting Celsius to Fahrenheit, printing the Fibonacci series, calculating factorials, printing even numbers in a range, grading based on total marks, identifying vowels and consonants, and printing the first 10 natural numbers. Each program includes user input prompts and outputs the results. The document serves as a practical guide for beginners in Python programming.

Uploaded by

sinhapiyushraj3
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/ 10

4.WAP to find square root of a number.

Programs:

n1= int(input(“Enter the number”))


n2 = n1**0.5
print("The square root of",n1,"is:",n2)

Output:
5. WAP to swap two variables.

Programs:
x=input("Enter the variable 'x’:”)
y=input("Enter the variable ’y’”)
temp=x
x=y
y=temp
print("After swapping“)
print('x=‘,x)
print('y=',y)
Output:
6. WAP to convert temperature in Celsius to Fahrenheit.
Programs:

n1=float(input("Enter the temperature in celsius:")


n2=(n1*1.8)+3.2
print(n1,'degree celsius equal to',n2,'degree fahrenheit')

Output:
7. WAP to print Fabonacci series.

Programs:

n1=int(input("Enter the number:"))


x=0
y=1
print(x)
print(y)
for i in range (0,8):
print(x+y)
temp=x
x=y
y=temp+y

Output:
8. WAP to find factorial of a number.

Programs:

num=int(input("Enter a number:"))
factorial=1
if num<0:
print("Sorry, factorial does not exist for negative
numbers")
elif num==0:
print("The factorial of 0 is 1")
else:
for i in range (1,num+1):
factorial=factorial*i
print("The factorial of", num,"is", factorial)
Output:
9. WAP to print even numbers between a specific range.

Programs:

start=int(input("Enter the start of range:"))


end=int(input("Enter the end of range:"))
for num in range (start,end+1):
if num%2==0:
print(num,end="")

Output:
10. WAP to display results of students based on
total marks.

Programs:

n1=int(input("Enter the total marks:"))


if 100>=n1>85:
print("A Grade")
elif 85>=n1>60:
print("B Grade")
elif 60>=n1>40:
print("C Grade")
elif 40>=n1>30:
print("D Grade“)
else:
print("You are fail")

Output:
11. WAP to enter a character from user and find out its
consonant or vowel.

Programs:
ch=input("Enter a character:")
if(ch=='A' or ch=='a' or ch=='E' or ch=='e' or ch=='I' or
ch=='i' or ch=='O' or ch=='o' or ch=='U' or ch=='u’):
print(ch,"is a vowel")
else:
print(ch,"is a consonant")

Output:
12. WAP to print first 10 natural numbers.
Programs:

print("=====The first 10 Natural Numbers====")


for i in range(1,11):
print(i)

Output:
THANK
THANK
YOU
YOU

You might also like