In: Computer Science
PYTHON program that:
Asks for a name, and then displays "Welcome student" plus your name on the screen. (concatenate your name after the string) and prompts the user for 2 numbers, then calculates and displays the sum, product and average.
Code image :
Code :
# name input from the user
name = raw_input("Enter your name :")
pre_text = "Welcome student"
print pre_text + name
# if you need space between text and name use : print pre_text + "
" + name
# numbers input from the user
num_1 = int(input("Enter first number :"))
num_2 = int(input("Enter second number :"))
sm = num_1 + num_2
pro = num_1*num_2
ave = (num_1+num_2)/2
print "Sum = ",sm
print "Product = ",pro
print "Average = ",ave
'''
Note : If your using python latest version,
use braces after print.
Ex : print("Sum = ",sm)
'''