Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON:1.Assume that message is a String variable. Write a statement to display

ID: 3875041 • Letter: P

Question

PYTHON:1.Assume that message is a String variable. Write a statement to display its value on standard output.

2.Assume that word is a String variable. Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of  word on a line by itself on standard output.

3.Two variables, num and cost have been assigned values. Write a single statement that outputs num and cost to standard output. Print both values (num first, then cost), separated by a space on a single line that is terminated with a newline character. Do not output any thing else.

4. Write a single statement that will print the message "first is" followed by the value of first, and then a space, followed by "second = ", followed by the value of second. Print everything on one line and go to a new line after printing. Assume that the variables have already been given values. Instructor Notes: There should be a space between the string "first is" and the value of the first variable.

5.Write some code that reads in a name and an age into the variables name and age. It then prints the message "The age of NAME is AGE" on a line by itself, where NAME and AGE represent the values read into the variablesname and age respectively. For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70" on a line by itself. There should NOT be a period in the output.Instructor Notes: The age needs to be an integer, not a string.

6.Write some code that reads a value representing a name into the variable name then prints the message "Greetings, NAME!!!" on a line by itself where NAME is replaced the value that was read into name. For example, if your code read in "Hassan" it would print out "Greetings, Hassan!!!" on a line by itself.

Instructor Notes: If you see a (backslash) in front of the exclamation marks, it shouldn't be there; some browsers seem to erroneously display it.

Explanation / Answer

1)
#printing string message on standard output
message='this is python'
print(message)

Output:
Save the above file as 1.py
Run the file on python IDLE, press F5
>>this is python


--------------------------------------------------------
2)
#set string value of today word
todayWord='python'
#printing string message on standard output
print('Today's Word-Of-The-Day is:',todayWord)

Output:
Save the above file as 2.py
Run the file on python IDLE, press F5
>>Today's Word-Of-The-Day is: python

--------------------------------------------------------
3)
#Set num value
num=1
#set cost value
cost=100

#print num and cost to standard output
#separated by cost
print(num,' ',cost)

Output:
Save the above file as 3.py
Run the file on python IDLE, press F5
>>1 100
--------------------------------------------------------
4)
#Set first value
first=1
#set second value
second=2

#print first and second to standard output
#separated by space
print('first is',first,'second is ',second)

Output:
Save the above file as 4.py
Run the file on python IDLE, press F5
first is 1 second is 2

--------------------------------------------------------
5)
#read name from user
name=input('Enter name : ')
#read age from user
age=int(input('Enter age :'))

#print name and age to standard output
print('The age of ',name,' is ',age)

Output:
Save the above file as 5.py
Run the file on python IDLE, press F5

Enter name : Rohit
Enter age :70
The age of Rohit is 70
--------------------------------------------------------
6)
#read name from user
name=input('Enter name : ')
#print name to standard output
print('Greetings, ',name,'!!!')

Output:
Save the above file as 6.py
Run the file on python IDLE, press F5

Enter name : Hasan
Greetings, Hasan !!!