Fundamentals 2 min read

Basic Python Programming Exercises: Summation, Square Roots, Triangle Area, Random Numbers, and More

This article presents a collection of basic Python programming exercises, covering numeric summation, square roots, triangle area calculation, random number generation, parity checks, leap year detection, prime testing, factorials, multiplication tables, numeric type identification, base conversions, greatest common divisor, and calendar generation.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Basic Python Programming Exercises: Summation, Square Roots, Triangle Area, Random Numbers, and More

1. Python numeric sum: calculate the sum of a series of numbers.

2. Square root: example \u221A16 = 4.

3. Triangle area: using Heron's formula (semi‑perimeter * (s‑a)*(s‑b)*(s‑c))^0.5.

4. Generate random numbers.

5. Determine odd or even numbers.

6. Determine leap years.

7. Test whether a number is prime.

8. Compute factorials.

9. Display the multiplication table (九九乘法表).

10. Identify whether a value is a number (requires importing a library).

11. Convert decimal numbers to binary, octal, and hexadecimal using bin(), oct(), and hex().

12. Find the greatest common divisor (GCD) of two numbers.

13. Generate a calendar.

This collection serves as a quick reference for beginners learning fundamental Python programming concepts.

PythonProgrammingAlgorithmsFundamentalsexercises
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.