Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Programming

Uploaded by

deepika.rjangir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Programming

Uploaded by

deepika.rjangir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

PYTHON PROGRAMMING

Q1.To find Personal Information Like Name,Father’s Name,Class,School Name.


~ name = "Bhavika Jangir"
fathers_name = "Rakesh Jangir"
class_name = "9th Grade"
school_name = "Vandana International School"
print("Personal Information:")
print(f"Name: {name}")
print(f"Father's Name: {fathers_name}")
print(f"Class: {class_name}")
print(f"School Name: {school_name}")
~Personal Information:
Name: Bhavika Jangir
Father's Name: Rakesh Jangir
Class: 9th Grade
School Name: Vandana International School

Q2. To find the square of number 7.


~ number = 7
square = number ** 2
print(f"The square of {number} is {square}")
~The square of 7 is 49

Q3.To find the sum of two numbers 15 and 20.


~ num1 = 15
num2 = 20
sum_of_numbers = num1 + num2
print(f"The sum of {num1} and {num2} is {sum_of_numbers}")
~ The sum of 15 and 20 is 35.
Q4. To convert length given in kilometers into meters.
~ kilometers = 5
meters = kilometers * 1000
print(f"{kilometers} kilometers is equal to {meters} meters")
~ 5 kilometers is equal to 5000 meters

Q5.Program to check if a person can vote or not.


~ age = int(input("Enter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
~ OUTPUT _
#1. Enter your age: 20
You are eligible to vote.
#2. Enter your age: 16
You are not eligible to vote.

Q6. To print first 10 natural numbers.


~ for i in range(1, 11): print(i)
~1
2
3
4
5
6
7
8
9
10
Q7. To print first ten even numbers.
~ for i in range(2, 21, 2): print(i)
~2
4
6
8
10
12
14
16
18
20

Q8. To calculate surface area and volume of a cuboid.


~
length = float(input("Enter the length of the cuboid: "))
width = float(input("Enter the width of the cuboid: "))
height = float(input("Enter the height of the cuboid: "))

surface_area = 2 * (length * width + length * height + width * height)


volume = length * width * height

print(f"The surface area of the cuboid is {surface_area} square units.")


print(f"The volume of the cuboid is {volume} cubic units.")
~ Enter the length of the cuboid: 4
Enter the width of the cuboid: 3
Enter the height of the cuboid: 5
The surface area of the cuboid is 94.0 square units.
The volume of the cuboid is 60.0 cubic units.
Q9. To check the grade of a student.
~ marks = float(input("Enter the marks obtained by the student: "))

if marks >= 90:


grade = 'A+'
elif marks >= 80:
grade = 'A'
elif marks >= 70:
grade = 'B'
elif marks >= 60:
grade = 'C'
elif marks >= 50:
grade = 'D'
else:
grade = 'F'
print(f"The student's grade is: {grade}")
~
Enter the marks obtained by the student: 85
The student's grade is: A

Q10. Create a list of first 10 even numbers, add 1 to each list item and print the final
results.

~
even_numbers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
even_numbers_plus_one = [num + 1 for num in even_numbers]

print("Original list of even numbers:", even_numbers)


print("List after adding 1 to each item:", even_numbers_plus_one)
~Original list of even numbers: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
List after adding 1 to each item: [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]

You might also like