0% found this document useful (0 votes)
178 views

Python Answers

The document contains 3 code snippets that demonstrate different programming concepts: 1) A program to convert weight between pounds and kilograms by asking the user to input their weight in either unit and printing the conversion. 2) A program that checks the length of a user-input name, printing a message if the name is too short or long while accepting names of acceptable length. 3) A program that calculates the down payment on a $1 million house based on whether the buyer has good or average credit, printing the payment amount using formatted strings.

Uploaded by

Mohammad Muquim
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)
178 views

Python Answers

The document contains 3 code snippets that demonstrate different programming concepts: 1) A program to convert weight between pounds and kilograms by asking the user to input their weight in either unit and printing the conversion. 2) A program that checks the length of a user-input name, printing a message if the name is too short or long while accepting names of acceptable length. 3) A program that calculates the down payment on a $1 million house based on whether the buyer has good or average credit, printing the payment amount using formatted strings.

Uploaded by

Mohammad Muquim
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
You are on page 1/ 2

Ques. Write a program to convert someone’s weight from pound to kg.

Ask
the user to enter their weight in either pound or kg and thn convert it into
another unit.

Ans.

pounds = float(input('Enter weight in Pounds to Convert into Kilograms:'))

kilo_grams = pounds * 0.453592

print(pounds,' Pounds are equal to', kilo_grams,'Kilograms (Kgs)')

Ques. If name is less than 3 characters long Print Name must be at least 3
char Otherwise if it’s more than 50 chars long Print Name can be a max of
50 characters Otherwise Print name looks good

Ans:

s=(input('Enter Your Name-'));

l=len(s);

if l<3:

print("Name must be atleast 3 Character")

elif l>50:

print("Name must be atmost 50 Character")

else:

print('Name looks Good')

Ques. Price of a house is $1M. If buyer has good credit, they need to put
down 10% otherwise they need to put down 20%. print the down Payment.
(Use formatted string)

Ans:

print('Price of house = $1M')


p1=float((1000000*10)/100)

p2=float((1000000*20)/100)

ch=(input('Enter Credits (G for good Otherwise A):'))

if ch=='G':

print('Down Payment= ',p1)

elif ch=='A':

print('Down Payment= ',p2)

else:

print('Wrong Input')

You might also like