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

Anyone understand how to write these programs? please help thank you VARIABLES *

ID: 3694790 • Letter: A

Question

 Anyone understand how to write these programs? please help thank you   VARIABLES *  *************  1) Write a program that sets a variable equal to 28 and then prints it on     the screen.  2) Write a program that sets variables x and y to 33 and 26 respectively,     and then prints their sum on the screen.  3) Write a program that sets x to 72 and y to 99, stores the sum of x and     y in a variable called z and then prints z. What is printed in the     screen?  4) Write a program that starts off a variable at 0, and then it increments     it 5 times, printing whatever is stored in the variable after each     increment.  5) Assuming that x is set to 11, and y is set to 3, write a statement that     prints 113 on the screen using these variables. Then write a statement     that prints 14 on the screen using these variables.  6) Write a program that reads a value from the user, and then adds that     value to a variable three times, printing the updated value after each     addition.  7) What's wrong with the following program? Trace it if you can't figure     out the problem.         a = 2          b = 3          b = a + c          print a  8) You're working with two variables called x & y. Write a piece of code     that swaps their values (imagine you had two cups filled with different     liquids. How would you swap those liquids?)  9) Trace:         x = 11          y = 3          z = x % y          print z          z = x / y          print z          x = x % y          z = (2 + 3) * 5 / 3 + 8 - 1          print z          y = x          x = x + x          print y          y = x          x = z          z = y          y = 1 - 1 - 1          print x y z          print x + y + z          print "x" "y" "z"          print "x" y "z"  10) What happens when you try to run the following line of code:         7 = x  11) Explain what happens in the following program:         x = 1          x = 1          x = 1  12) Trace the value of the variable y for each statement         y = 1          x = y + 1          z = y + y          y = y + y          z = y + y  13) Read a value from the user into a variable, and then print the square      of that value.  14) Generate a random number and store it in a variable. Read a number      from the user and store that in a variable, too. Print the remainder      of the random number divided by the one provided by the user.  15) Ask the user for the upper limit. Then generate a random number up to      that limit, and print it on the screen. So for eg, if the user enters      a 100, your random number can be between 0-100. (hint: modulus      operator)  16) Write a program that asks the user for the current temperature in      fahrenheit, and then converts it to Celcius. The formula is C =      (F-32)/1.8  17) Write a program that asks the user for their height in inches, and      then converts it to feet & inches. (hint: division and modulus)  18) Write a program that asks the user for time in seconds, and then      prints it in HH:MM:SS notation.  19) Finish the following sentences/fill in the blanks (wherever the dots      appear):           a) If a variable name appears ..., you're trying to store a value in it.          b) If a variable name appears ..., you're trying to recall the value stored in it.          c) The ONLY time a variable changes is when it appears on ...          d) Anytime you want to temporarily store a value, ...          e) A variable can hold only ... value at a time.          f) You can change the ... stored in a variable, but you cannot change its ...          g) Two variables cannot have the same ...          h) In general, variable ... must be letters/words. They cannot be numbers. 

Explanation / Answer

Multiple Questions :

1.

x = 28

print x

2.

x = 33
y = 26
print "sum = ",x+y

3.

x = 72
y = 99
z = x+y
print z

[value printed is = 171]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote