Professional Documents
Culture Documents
Capsule 2 Do It Ypurself Durgesha Dalvi
Capsule 2 Do It Ypurself Durgesha Dalvi
Q1) Write a program that prompts the user to input a year, checks
whether it's a leap year or not, and then prints the result.
#Write a program that prompts the user to input a year, checks whether it's a leap year or not, and
then prints the result.
else:
vowels = 'aeiouAEIOU'
count = 0
if char in vowels:
count = count+ 1
def main():
if name.lower().startswith('a'):
print(name)
if __name__ == "__main__":
main()
Q4) Write a Python program that takes a list of 10 integers as input.
Your program should iterate through the list and print the following:
• For each even number encountered, print the number squared.
• For each odd number encountered, print the number cubed.
def main():
if num % 2 == 0:
print(num ** 2)
print(num ** 3)
main()
Q5) Imagine you're ordering flowers from a local delivery service.
They offer a selection of beautiful flowers, including roses. Each
rose is priced at Rs. 10. Along with your choice of roses, you'll need
to provide the count of roses you wish to order and the delivery
distance. The delivery charges are as follows: Rs. 25 for distances
within 5 kilometers, Rs. 50 for distances between 5 and 10
kilometers, and Rs. 75 for distances greater than 10 kilometers.
Write a Python program that prompts the user to enter the count of
roses and the delivery distance, then calculates and displays the
total price to pay, including both the cost of roses and the delivery
charge.
def calculate_delivery_charge(distance):
if distance <= 5:
return 25
return 50
else:
return 75
def main():
rose_price = 10
delivery_charge = calculate_delivery_charge(delivery_distance)
main()