Python Program To Convert Celsius To Fahrenheit. Conversion From Celsius To Fahrenheit Temperature
Python Program To Convert Celsius To Fahrenheit. Conversion From Celsius To Fahrenheit Temperature
2 Write a program to enter two integers and perform all arithmetic operations on them.
3Create Functions in Python to calculate Area and Perimeter of Circle. Write a Python program to ask
user to input their choice 1 or 2. If choice is 1 calculate Area of Circle, if choice is 2 calculate Perimeter of
Circle otherwise show an error message.
if y < 0:
elif y == 0:
return 0
elif y == 1:
return x
else:
return x + multiply(x, y - 1)
print(multiply(3, 5));
num = 1
for i in range(row):
for j in range(i+1):
print(num, end=" ")
num = num+1
print()
6. ̥Create
–l a function to check the given string is palindrome. If
Palindrome then return True otherwise return False.
print(isPalindrome(string))
7.
7.Create a Function to Guess_Numbers(), which ask a number between 1 to
6 form user. Generate a random number between 1 to 6 through random
module and check the User Guess is matched or not. Display appropriate
message,.
Ans
import random
# Start a loop that continues until the guessed number matches the target number
while target_num != guess_num:
# Prompt the user to input a number between 1 and 10 and convert it to an integer
guess_num = int(input('Guess a number between 1 and 10 until you get it right : '))
# Print a message indicating successful guessing once the correct number is guessed
print('Well guessed!'
9. Write a function in python to count the number of lines in a text file ‘STORY.TXT’ which is starting with an alphabet ‘A’ .
file=open('STORY.TXT','r')
lines = file.readlines()
count=0
for w in lines:
if w[0]=="A" or w[0]=="a":
count=count+1
print(“Total lines “,count)
file.close()