CPSC111-Introduction to computing By Dr. Ahmed Malki – Asg. #1 (Summer-16)
What is your name? Muhammad Ali
Hello Muhammad Ali!
Your name starts with an M, ends with an i and is 12 Characters
long. Nice meeting you!
Also, write the code that will demonstrate your function.
#ask for a user's name and print a greeting
#and also get the first and last letter of the user's name and the length of
yourName = raw_input ('What is your name? ')
print 'Hello ' + yourName +"!"
print 'Your name starts with an',yourName + ', ends with an'
,yourName[len(yourName)-1] +' and is', str( len(yourName) ) +' Characters
print 'Nice meeting you!'
Study the program below. It will input a weight (in pounds) and convert the weight to kilograms.
The result of the conversion will be output to the console.
The formula used to convert pounds to kilograms is as follows;
kilogram = pounds * 0.45359
# Program to convert LBs to KGs
# This function will input the pounds from the user
def get_pounds() :
user_input = raw_input("Please enter your weight in pounds (LB) : ")
pounds = float(user_input)
You have entered ", pounds, " LB\n"
Assigned: Monday, July 18