Python GrundlagenEinfach

Potenz einer Zahl

Detaillierte Anleitung und Python-Implementierung für das Problem „Potenz einer Zahl“.

Problemstellung

Einfach

Schreiben Sie eine Funktion power(base, exp), die zwei nicht negative ganze Zahlen base und exp akzeptiert und base hoch exp zurückgibt (d. h. base^exp). Beachten Sie, dass jede hoch 0 hochgezogene Zahl 1 ist.

Einschränkungen
  • 0 <= base <= 100
  • 0 <= exp <= 20

Beispiele

Example 1
Input
base = 2, exp = 10
Output
1024
Explanation

2^10 = 1024.

Example 2
Input
base = 5, exp = 0
Output
1
Explanation

Any number raised to the power 0 is 1.

Example 3
Input
base = 3, exp = 4
Output
81
Explanation

3^4 = 3 × 3 × 3 × 3 = 81.

Need a Hint?
Erwägen Sie die Verwendung von Basics-spezifischen Datenstrukturen wie Mengen oder Heaps.
Edge Cases to Watch
  • Leere Eingabestrukturen
  • Einzelelementeingaben
  • Große numerische Grenzen

Bereit zur Lösung?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Im Editor öffnen
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Empfohlene Python-Ressourcen

Erweitern Sie Ihr Wissen mit zugehörigen interaktiven Tutorials, Spickzetteln und Codevergleichen.