0% found this document useful (0 votes)
4 views6 pages

Algorithm - 10 STD

The document outlines a series of Python programming tasks, each with a specific aim and algorithm. It includes programs for calculating the area and circumference of a circle, finding factorials, checking leap years, displaying multiplication tables, creating patterns, calculating simple interest, finding averages, checking even or odd numbers, manipulating lists, grading based on marks, concatenating strings, and finding string lengths. Each task is presented with a clear algorithm and corresponding code implementation.

Uploaded by

nivedha072010
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)
4 views6 pages

Algorithm - 10 STD

The document outlines a series of Python programming tasks, each with a specific aim and algorithm. It includes programs for calculating the area and circumference of a circle, finding factorials, checking leap years, displaying multiplication tables, creating patterns, calculating simple interest, finding averages, checking even or odd numbers, manipulating lists, grading based on marks, concatenating strings, and finding string lengths. Each task is presented with a clear algorithm and corresponding code implementation.

Uploaded by

nivedha072010
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

1) Aim: To write the python program to calculate the area and circumference

of a circle

Algorithm:

1. Start
2. Prompt the user to enter the radius of the circle.
3. Read the radius as a floating-point number.
4. Calculate the area of the circle using the formula:
area = 3.14 × radius × radius
5. Calculate the circumference of the circle using the formula:
circumference = 2 × 3.14 × radius
6. Display the area of the circle.
7. Display the circumference of the circle.
8. End

Program:

radius=float(input("enter the radius of the circle:"))


area=3.14*radius*radius
circumference=2*3.14*radius
print ("area of the circle:",area)
print ("circumference of the circle:” circumference)

2) Aim: To write the python program, to find the factorial of a number


Algorithm:

1. Start
2. Input a positive integer num
3. Initialize a variable factorial to 1
4. Repeat the following steps for all integers i from 1 to num (inclusive):
o Multiply factorial by i and store the result back in factorial
5. End Loop
6. Output the value of factorial as the factorial of the number num
7. End

Program:

num=int(input("enter a positive number:"))


factorial = 1
for i in range(1,num+1):
factorial =factorial *i
print("the factorial of ",num,"is",factorial)
3) Aim: To write the python program to check for a leap year

Algorithm:

1. Start
2. Input a year from the user and store it in a variable year.
3. Check Condition:
o If the year is divisible by 4 AND not divisible by 100, OR
o The year is divisible by 400,
o Then it's a leap year.
4. Output Result:
o If the condition is True, print "year is a leap year".
o Otherwise, print "year is not a leap year".
5. End

Program

year=int(input("enter a year:"))
if(year % 4==0 and year %100!=0)or (year % 400==0):
print(year,"is a leap year")
else:
print(year," is not a leap year")

4) Aim: To write the python program to display multiplication table

Algorithm:

1. Start
2. Input a number from the user and store it in variable num.
o Prompt: "Enter a number to display its multiplication table:"
3. Display the message: "Multiplication table for <num>"
4. Initialize a counter variable i to 1.
5. Repeat steps 6–7 while i is less than or equal to 10:
6. Compute the product: product = num * i
7. Display the result in the format: num x i = product
8. Increment i by 1
6. End

Program:

num=int(input("enter a number to display its multiplication table:"))


print("multiplication table for",num)
for i in range(1,11):
print(num,"x",i,"=",num*i)
5
5) Aim: To write the python program to make pattern in Right-angled
triangle
Algorithm:

1. Input row size:


o Prompt the user to input the number of rows (rows).
2. Loop through each row:
o Use a for loop (i from 1 to rows, inclusive) to iterate over the number
of rows.
3. Loop through each column (stars in a row):
o For each row i, use a nested for loop (j from 1 to i, inclusive) to print
* that many times.
4. Newline after each row:
o After printing stars for one row, print a newline using print() with no
arguments.

Program

rows = int(input("Enter the row size for the pattern: "))


for i in range(1, rows + 1):
for j in range(1, i + 1):
print("*", end="") # print stars on the same line
print()

6)Aim: To write the program to Calculate the Simple Interest

Algorithm:

1. Start
2. Input the principal amount (p) from the user.
3. Input the rate of interest (r) from the user.
4. Input the time in years (t) from the user.
5. Calculate simple interest using the formula:
si = (p × r × t) / 100
6. Display the value of simple interest (si).
7. End

Program

p = float(input("Enter principal amount: "))


r = float(input("Enter rate of interest: "))
t = float(input("Enter time in years: "))
si = (p * r * t) / 100
print("Simple Interest:", si)
7) Aim: To write the python program ,to find the average of the given three
numbers.

Algorithm:

1. Start
2. Prompt the user to enter the first number, store it in variable a
3. Prompt the user to enter the second number, store it in variable b
4. Prompt the user to enter the third number, store it in variable c
5. Calculate the average using the formula:
average = (a + b + c) / 3
6. Display the result as: "Average: ", average
7. Stop

Program:

def average_3():
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
c = float(input("Enter third number: "))
print("Average:", (a + b + c) / 3) # Calculate and print the average
average_3()

8) Aim: To write the python program to check the Even or Odd Number

Algorithm:

1. Start
2. Input a number from the user and store it in a variable number.
3. Check if number % 2 == 0
o If True, then:
 Display that the number is even.
o Else:
 Display that the number is odd.
4. End

Program

number=int(input("enter a number:"))
if number %2==0:
print(number,"is an even number")
else:
print(number,"is an odd number")

9) Aim: To write the program to append the element to a list


Algorithm:
1. Initialize the list numbers = [1, 2, 3, 4, 5]
2. Prompt the user to enter a number
3. Convert the input from string to integer (int(input(...)))
4. Append the new number to the list using append()
5. Print the updated list
Program:
numbers=[1,2,3,4,5]
new_number=int(input("enter a number to add to the list:"))
[Link](new_number)
print("updated list:",numbers)

10) Aim:To writhe the python program to extend a list with another
Algorithm:
1. Initialize two lists:
o list1 = [1, 2, 3]
o list2 = [4, 5, 6]
2. Extend list1 by appending all elements from list2 to it.
o This modifies list1 in place (does not return a new list).
o After this step, list1 = [1, 2, 3, 4, 5, 6]
3. Print the updated list:
o Output: "updated list: [1, 2, 3, 4, 5, 6]"
Program:
list1=[1,2,3]
list2=[4,5,6]
[Link](list2)
print("updated list:",list1)

11) Aim: To write the Python program to find the grading based on Marks
Algorithm:
1. Start
2. Prompt the user to input their marks
o Store the input in variable marks
3. Check the value of marks using conditional statements:
o If marks >= 90:
→ Print "A grade"
o Else if marks >= 80:
→ Print "B grade"
o Else if marks >= 70:
→ Print "C grade"
o Else if marks >= 60:
→ Print "D grade"
o Else if marks >= 50:
→ Print "you can do better"
o Else:
→ Print "need to work harder"
4. End
Program:
marks=int(input("enter you marks"))
if(marks>=90):
print("A grade")
elif(marks>=80):
print(" B grade")
elif(marks>=70):
print("C grade")
elif(marks>=60):
print("D grade")
elif(marks>=50):
print("you can do better")
else:
print("need to work harder")

12)Aim: To write th Python Program to Concatenate Two Strings Using +


Operator
Algorithm:
1. Start
2. Initialize a string variable str1 with the value "WsCube".
3. Initialize another string variable str2 with the value "Tech".
4. Concatenate str1, a space " ", and str2 using the + operator.
o This forms the new string: "WsCube Tech"
5. Store the result of the concatenation in a new variable result.
6. Print the value of result.
7. End
Program:
tr1 = "WsCube"
str2 = "Tech"
result = str1 + " " + str2 # The + operator joins two strings
print(result) # Output: WsCube Tech

13) Aim: To find the python program to find the length of the characers.
(Algorithm Steps):
1. Assign a string to a variable:
text = "Hello, World!" — stores the string in a variable named text.
2. Calculate length:
len(text) — the len() function returns the number of characters in the string,
including spaces and punctuation.
3. Store result:
length = len(text) — saves the result (13) to a variable named length.
4. Print result:
print(length) — outputs 13 to the console.
Program:
text = "Hello, World!"
length = len(text) # len() directly gives the number of characters in the string
print(length)

You might also like