Computer Science 1
Computer Science 1
Programs:
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:
Output:
7. WAP to print Fabonacci series.
Programs:
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:
Output:
10. WAP to display results of students based on
total marks.
Programs:
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:
Output:
THANK
THANK
YOU
YOU