بخشی از مجموعه

چندین نمونه کد

~1 دقیقه مطالعه • بروزرسانی ۶ مهر ۱۴۰۴

Program Overview

This Python program receives an integer n from the user and calculates the result of n × n × n × n.
This is equivalent to computing n⁴ (n to the power of 4), and is useful for practicing exponentiation and multiplication logic.


Python Code:


# Get an integer from the user
n = int(input("Enter an integer: "))

# Calculate n to the power of 4 using multiplication
result = n * n * n * n

# Display the result
print("\n--- Result ---")
print("n × n × n × n =", result)

Sample Output:


Enter an integer: 2  
--- Result ---  
n × n × n × n = 16

Explanation:

- The input n is received using input() and converted to an integer
- The expression n × n × n × n is evaluated using direct multiplication
- This is equivalent to n**4 but uses only the multiplication operator as requested
- The result is printed clearly for the user


نوشته و پژوهش شده توسط دکتر شاهین صیامی