0% found this document useful (0 votes)
3 views5 pages

Computer 8 Dec

Uploaded by

ttopup23
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)
3 views5 pages

Computer 8 Dec

Uploaded by

ttopup23
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/ 5

Class 10th(Computer Application)

Python Programs

 Write a program to read distance in miles and print in kilometers.

1.miles = float(input("Enter a distance in miles:"))


2.kilometers = 1.609*miles
3.print("the distance of",miles,"miles in kilometers
is",kilometers)

OUTPUT
Enter a distance in miles:4.5

the distance of 4.5 miles in kilometers is 7.2405

 Write a program to compute "how many days is a millions


seconds?"

1.Sec = 1e6 #1 million = 1000000


2.minutes = sec/60
3.hours = minutes/60
4.days = hours/24
5.print("One million seconds are equal to",days)

OUTPUT
One million seconds are equal to 11.574074074074074
 Program to accept three integers and print the largest of the
three.

1.x = float(input("Enter first number:"))


2.y = float(input("Enter second number:"))
3.z = float(input("Enter third number:"))
4.max=x
5.if(y>max):
6.max=y
7.if(z>max):
8.max=z
9. print("Largest number is:",max)

OUTPUT

Enter first number:4.6

Enter second number:8.2

Enter third number:7

Largest number is: 8.2

 Program that takes a number and check whether the given


number is odd or even.

1.num = int(input("Enter a number:"))


2.if(num%2)==0:
3.print(num,"is even.")
4.else:
5. print(num,"is odd.")

OUTPUT

Enter a number:9

9 is odd.
 Program that takes a number and print table of that's
number.

1.num = int(input("Enter an integer number:"))


2.for i in range(1,11):
3.print(num,"*",i,"=",num*i)

OUTPUT
Enter an integer number:7
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70

 Program to print sum of natural numbers between 1 to 10

1.sum = 0
2.for a in range(1,11):
3.sum+=a
4.print("Sum of netural numbers upto 10
in",a,"is",sum)
OUTPUT
Sum of netural numbers upto 10 in 1 is 1
Sum of netural numbers upto 10 in 2 is 3
Sum of netural numbers upto 10 in 3 is 6
Sum of netural numbers upto 10 in 4 is 10
Sum of netural numbers upto 10 in 5 is 15
Sum of netural numbers upto 10 in 6 is 21
Sum of netural numbers upto 10 in 7 is 28
Sum of netural numbers upto 10 in 8 is 36
Sum of netural numbers upto 10 in 9 is 45
Sum of netural numbers upto 10 in 10 is 55

 Progam to calculate and print the first n fibonacci series of


the netural numbers using python while loop.

1.n = int(input("Enter the number of fibonacco


series:"))
2.num1=0
3.num2=1
4.next_num=num2
5.count=1
6.while count<=n:
7.print(next_num, end=" ")
8.count+=1
9.num1, num2 = num2, next_num
10. next_num = num1 + num2

OUTPUT
Enter the number of fibonacco series:8

1 2 3 5 8 13 21 3
 Write a program to know the number is prime or not.

1.num = 17
2.if num>1:
3. for i in range(2,(num//2)+1):
4. if(num%i)==0:
5. print(num,"is not a prime number.")
6. break
7. else:
8. print(num,"is a prime number.")
9. else:
10. print(num,"is not a prime number.")

OUTPUT

17 is a prime number.

You might also like