python

This zyLab activity prepares a student for a full programming assignment. Warm up exercises are typically simpler and worth fewer points than a full programming assignment, and are well-suited for an in-person scheduled lab meeting or as self-practice.


A variable like user_num can store a value like an integer. Extend the given program as indicated.

Output the user's input. (2 pts)
Output the input squared and cubed. Hint: Compute squared as user_num * user_num. (2 pts)
Get a second user input into user_num2, and output the sum and product. (1 pt)

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.

Enter integer:
4
You entered: 4
4 squared is 16
And 4 cubed is 64 !!
Enter another integer:
5
4 + 5 is 9
4 * 5 is 20

Answer :

Cytokine

In python 3:

user_num = int(input("Enter integer: "))

print("You entered: {}".format(user_num))

print("{} squared is {}".format(user_num, user_num**2))

print("And {} cubed is {}!!".format(user_num, user_num**3))

user_num2 = int(input("Enter another integer: "))

print("{} + {} is {}".format(user_num, user_num2, user_num + user_num2))

print("{} * {} is {}".format(user_num, user_num2, user_num * user_num2))

I hope this helps!

Following are the Python program to input value and calculate its square and cube value.

Program Explanation:

  • Defining a variable "user_num" that inputs integer value.
  • In the next step, three print method is used that first prints input variable value and in the next two print method, it calculates square and cube value that print its value.
  • After print, its value another variable "user_num1" is declared that uses the print method.
  • Inside this, it adds and multiplies the input value and prints its values.

Program:

user_num = int(input("Enter integer: "))#defining a variable user_num that input value

print("You entered:",user_num)#using print method to print input value

print(user_num," squared is ", user_num**2)#calculating the square value and print its value

print("And", user_num , "cubed is", user_num**3, "!!")#calculating the cube value and print its value

user_num1 = int(input("Enter another integer: "))#defining a variable user_num that input value

print( user_num,"+",user_num1, "is", user_num + user_num1)#using print that add input value

print( user_num,"*",user_num1, "is", user_num *user_num1)#using print that multiply input value

Output:

Please find the attached file.

Learn more:

brainly.com/question/17961597

${teks-lihat-gambar} codiepienagoya

Other Questions