01- Python Top 10 Program01- Python Top 10 Program

Python Top 10 Program

Python Top 10 Program will teach you all basic program and how can you initiate the write a super code. Python is the preferred language for data science and machine learning. It offers sophisticated tools for data analysis, visualization, and the development of complicated machine learning models with libraries such as TensorFlow, Keras, and Scikit-learn.

Python skills are in high demand across a wide range of businesses. Python proficiency can lead to a variety of professional prospects in sectors such as data research, software engineering, and web development. Automation and scripting: Python is excellent for scripting and automating repetitive operations. Its ease of use enables developers to create scripts that save time and improve efficiency in a variety of activities.

Python’s simplicity and strong library support allow for rapid development and iteration. This enables developers to swiftly develop and test new ideas, making it ideal for startups and innovation-driven projects. Python is a cross-platform language, which means that code created for one operating system can be run on another with little to no changes.

1. Hello World Program:

print("Hello, World!")

2. Simple Calculator:

a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
print("Sum:", a + b)
print("Difference:", a - b)
print("Product:", a * b)
print("Quotient:", a / b)
3. Factorial of a Number:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = int(input("Enter a number: "))
print("Factorial:", factorial(num))

3. Factorial of a Number:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
num = int(input("Enter a number: "))
print("Factorial:", factorial(num))

4. Fibonacci Sequence:
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n - 1) + fibonacci(n - 2)
terms = int(input("Enter the number of terms: "))
print("Fibonacci sequence:")
for i in range(terms):
print(fibonacci(i))

5. Check for Prime Number:
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
num = int(input("Enter a number: "))
if is_prime(num):
print("Prime")
else:
print("Not prime")

6. Simple Interest Calculator:
p = float(input("Enter the principal amount: "))
r = float(input("Enter the rate of interest: "))
t = float(input("Enter the time period: "))
interest = (p * r * t) / 100
print("Simple Interest:", interest)

7. Check for Even or Odd:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")

8. Area of a Circle:
import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius * radius
print("Area:", area)

9. List Comprehension:
squares = [i ** 2 for i in range(10)]
print("Squares:", squares)

10 Simple File Handling:
# Writing to a file
with open("output.txt", "w") as file:
file.write("Hello, this is a sample text.")
# Reading from a file
with open("output.txt", "r") as file:
data = file.read()
print("Data from file:", data)

One thought on “Coding Skills – 01 – Python Top 10 Program”

Leave a Reply

Your email address will not be published. Required fields are marked *

Netflix’s Overall Architecture. Gold is money every thing else is credit