## Python is a widely used and popular programming language, and its short and readable syntax makes it easy for beginners to learn **Fundamental Programs for Beginners** .

There are many opportunities to learn coding with Python these days. Practicing programming in Python will help you become more familiar with the Python language and its syntax, making it easier to write and understand code in the future.

## Master Python: Discover the Top 50 Essential **Fundamental Programs for Beginners **and Beyond

In this article, we will look at 60 basic programs in Python. Fundamental Programs for Beginners Python Programming Examples to Learn and Solve will help you improve your problem-solving and critical thinking skills, help you break down complex problems into smaller, more manageable parts, and solve all parts. gives you an idea of how to find the problem. Solved.

### Discover the Magic of Summing Elements with this Game-Changing Program!

Lists in Python are similar to arrays in other programming languages. Write a Python program that finds the sum of all elements in a list list of **Fundamental Programs for Beginners**.

```
def arraySum(arr):
sum = 0
for i in arr:
sum += i
return sum
print(arraySum([1, 2, 3, 4, 5]))
```

**Output:**

15

### Python program to check whether a number is even or odd

Even numbers are divisible by 2, but odd numbers are not.Fundamental Programs for Beginners Use the modulo operator to check whether a number is completely divisible by 2.

**Also Read: Hostel management system project in python
**

```
def is_even(n):
if n%2==0:
return True
else:
return False
print(is_even(3))
```

**Output:**

False, True

### Python program to find the average of all elements

Create a list and print the average of all items in it. The number average is calculated by adding all the numbers and dividing by the number of those numbers.

```
def average(arr):
sum = 0
for i in arr:
sum += i
return sum / len(arr)
print(average([1, 2, 3, 4, 5]))
```

**Output:**

3.0

### Python program to count the number of vowels in a string

The vowels are “ah, e, i, o, u.” Write a Python program that checks the number of vowels present in a string.

```
def countVowels(str):
vowels = ['a', 'e', 'i', 'o', 'u']
count = 0
for i in str:
if i in vowels:
count += 1
return count
print('number of vowels in hello is '+str(countVowels('hello')))
```

**Output:**

number of vowels in hello is 2

### Python program to check if a string is a palindrome

A palindrome is a word that has the same content whether you read it from the front or from the back. Example – “Level”, “Nun”

```
my_str = 'malayalam'
print(my_str==my_str[::-1])
```

**Output:**

True

### Python **program** to reverse a list

Write a program to reverse the order of a list in Python using the two-pointer approach.

```
def reverse_list(arr):
left = 0
right = len(arr)-1
while (left < right):
temp = arr[left]
arr[left] = arr[right]
arr[right] = temp
left += 1
right -= 1
return arr
arr = [1, 2, 3, 4, 5, 6, 7]
print(reverse_list(arr))
# another and short approach
print(arr[::-1])
```

**Output:**

[7, 6, 5, 4, 3, 2, 1]

### Python program to find the factorial of a number

The factorial of a number is the product of all positive integers between 1 and that number. For example, the factorial of 5 is 5. = 5*4*3*2*1 = 120

```
def factorial(num):
if num == 1:
return 1
else:
return num * factorial(num - 1)
print(factorial(5))
```

**Output:**

120

### Python program to concatenate all the words in a list

```
arr = ['hello', 'world']
st = ''
for i in arr:
st += i
print(st)
```

**Output:**

helloworld

### Python program to remove all the vowels in a string

```
s = 'hello'
vowels = ['a', 'e', 'i', 'o', 'u']
newStr = ''
for i in s:
if i not in vowels:
newStr += i
print(newStr)
```

**Output:**

hll

### Armstrong **number** **program** **in** Python

An Armstrong number is a number equal to the sum of its own digits multiplied by the number of digits. For example, 371 is Armstrong’s number because 3^3 + 7^3 + 1^3 = 371.

```
n = 371
num_digits = len(str(n))
sum = 0
for digit in str(n):
sum += int(digit)**num_digits
print(sum == n)
```

**Output:**

True

### Python **program** to remove duplicates from a list

A set is a data structure that contains only unique elements. Remove all duplicate elements using Python statements.

```
my_list = [1, 2, 3, 2, 1]
new_list = list(set(my_list))
print(new_list)
```

**Output:**

[1, 2, 3]

**fibonacci** **sequence** program with basic Fundamental Programs for Beginners

The Fibonacci sequence is a series of numbers where each number is the sum of the previous two numbers. For example, the first numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, etc.

```
n = 10
a, b = 0, 1
print(a)
print(b)
for i in range(2, n):
c = a + b
print(c)
a, b = b, c
```

**Output:**

0 1 1 2 3 5 8 13 21 34

### Remove all odd elements in a list

```
arr = [1, 2, 3, 4, 5]
newArr = []
for i in arr:
if i % 2 == 0:
newArr.append(i)
print(newArr)
```

**Output:**

[2, 4]

### Leap Year Program in Python

Every four years, the calendar adds an extra day in the month of February, known as leap year. Fundamental Programs for Beginners While this may seem like a simple adjustment, the concept of leap year has deep historical and scientific significance.

```
year = 2000
if year % 400 == 0:
print('leap year')
elif year % 4 == 0:
print('leap year')
elif year % 100 == 0:
print('not a leap year')
else:
print('not a leap year')
```

**Output:**

leap year

### Prime Number Program in Python

**Fundamental Programs for Beginners:** A prime number is a natural number greater than 1 that is not the product of two smaller natural numbers. The first few prime numbers are 2, 3, 5, 7, and 11.

```
n = 7
is_prime = True
if n < 2:
is_prime = False
else:
for i in range(2, n):
if n % i == 0:
is_prime = False
break
if is_prime:
print("Prime")
else:
print("Not prime")
```

**Output:**

Prime

### LCM program with python

The least common multiple (LCM) of two or more numbers is the smallest number that is a multiple of all the numbers.Fundamental Programs for Beginners.

```
a = 6
b = 9
lcm = a
while lcm % b != 0:
lcm += a
print(f"LCM of {a} and {b} is {lcm}.")
```

**Output:**

LCM of 6 and 9 is 18.

### HCF program in python

The greatest common factor (HCF) of two or more numbers is the largest number that exactly divides all the numbers. Fundamental Programs for Beginners for example, the HCF of 15 and 20 is 5. This is because 5 is the largest number that exactly divides both 15 and 20.

```
a = 15
b = 20
if a > b:
smaller = b
else:
smaller = a
for i in range(1, smaller+1):
if (a % i == 0) and (b % i == 0):
hcf = i
print(f"HCF of {a} and {b} is {hcf}")
```

**Output:**

HCF of 15 and 20 is 5

### Python program to swap two numbers

```
first = 27
second = 4
temp = first
first = second
second = temp
print(f"After swapping, the first number is {first} and the second number is {second}")
```

**Output:**

After swapping, the first number is 4 and the second number is 27.

### Python program to print all prime numbers up to n

```
n = 10
for i in range(2, n+1):
is_prime = True
for j in range(2, i):
if i % j == 0:
is_prime = False
break
if is_prime:
print(i)
```

**Output:**

2 3 5 7

### Python program to find the greatest of three numbers

```
num1 = 10
num2 = 14
num3 = 12
if (num1 >= num2) and (num1 >= num3):
largest = num1
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
print(largest)
```

**Output:**

14

### Multiplication table program

```
num = 19
for i in range(1, 11):
print(num*i)
```

**Output:**

19 38 57 76 95 114 133 152 171 190

### Python program to sort an array(list)

```
numbers = [2, 3, 4, 1]
numbers.sort()
print(numbers)
```

**Output:**

[1, 2, 3, 4]

### Python program to convert all characters to uppercase

```
s = 'follow us'
newStr = ''
for i in s:
newStr += i.upper()
print(newStr)
```

**Output:**

FOLLOW US

### Python program to capitalize the first letter of each word

```
s = 'Learn Digitalgigs'
newStr = ''
for i in range(len(s)):
if i == 0 or s[i - 1] == ' ':
newStr += s[i].upper()
else:
newStr += s[i]
print(newStr)
```

**Output:**

Learn Digitalgigs

### Python program to convert all characters to lowercase

```
s = 'Fundamental Programs for Beginners'
newStr = ''
for i in s:
newStr += i.lower()
print(newStr)
```

**Output:**

Fundamental Programs for Beginners

### Python program to reverse a string

```
s = 'sgislatigidnrael'
newStr = ""
for i in s:
newStr = i + newStr
print(newStr)
```

**Output:**

learndigitalgigs

### Calculator Program in Python

We will write a basic calculator program that can add, subtract, multiply and divide.

```
def add(a,b):
return a+b
def sub(a,b):
return a-b
def multi(a,b):
return a * b
def div(a,b):
return a / b
print(add(10,15))
print(sub(13,10))
```

**Output:**

25 3

### Python program for Pyramid pattern

n=5 for i in range(0, n): for j in range(0, i+1): print("* ",end="") print("\r")

**Output:**

### Reverse Pyramid pattern

n=5 k = 2*n - 2 for i in range(0, n): for j in range(0, k): print(end=" ") k = k - 2 for j in range(0, i+1): print("* ", end="") print("\r")

**Output:**

### Continuous Character pattern program in Python

n = 5 num = 65 for i in range(0, n): for j in range(0, i+1): ch = chr(num) print(ch, end=" ") num = num + 1 print("\r")

**Output:**

### Python program to print Triangle

n=5 k = n - 1 for i in range(0, n): for j in range(0, k): print(end=" ") k = k - 1 for j in range(0, i+1): print("* ", end="") print("\r")

**Output:**

## Conclusion

In this article we have covered master Python programming with important examples Fundamental Programs for Beginners. Basic programs for beginners in Python on various Python topics. It will help you learn these concepts and apply them to various problems. To get familiar with problem solving in Python, we recommend starting by solving all the questions in this article.

**Also Read **

**Best Python Projects for Final Year Students with Source Code**

**How to generate QR code in Python?**

**What are some good Python Projects for Beginners?**

**Python Pandas : A Complete Introduction for Beginners**

**Automate Instagram Login Using Python**