Showing posts with label 100 Python Programs for Beginner. Show all posts
Showing posts with label 100 Python Programs for Beginner. Show all posts

Monday, 2 December 2024

Day 9 : Python Program to Convert Centimeters to Feet and Inches

 


def conversion(cm):

    

    total_inches = cm / 2.54

    feet = int(total_inches // 12) 

    inches = total_inches % 12 

    return feet, inches

cm = float(input("Enter length in centimeters: "))

feet, inches = conversion(cm)

print(f"{cm} cm is approximately {feet} feet and {inches:.2f} inches.")

#source code --> clcoding.com 

Saturday, 30 November 2024

Day 8 : Python Program to check whether the number is prime or not using recursion


def is_prime(number, divisor=2):

    if number <= 1:

        return False

    if divisor == number:  

        return True

    if number % divisor == 0:  

        return False

    return is_prime(number, divisor + 1) 

num = int(input("Enter a number: "))

if is_prime(num):

    print(f"{num} is a prime number.")

else:

    print(f"{num} is not a prime number.")

#source code --> clcoding.com 

 

Day 7 : Python Program to find Prime Number in a given Range

 



start = int(input("Enter the start of the range: "))

end = int(input("Enter the end of the range: "))


for num in range(start, end + 1):

    if num > 1 and all(num % i != 0 for i in range(2, num)):

        print(num)

        

 #source code --> clcoding.com 


Thursday, 28 November 2024

Day 5 : Python Program to Check Whether a Number is Positive or Negative

 


num = float(input("Enter a number: "))  

if num > 0: 

    print("Positive number")

elif num < 0:  

    print("Negative number")

else:  

    print("Zero")

#source code --> clcoding.com 

Day-4 Python Program Count the Number of Digit in a Number

 Python Program Count the Number of Digit in a Number



number = int(input("Enter a number: "))  
count = 0  
if number == 0:  
    count = 1
else:
    if number < 0:  
        number = -number
   
    while number > 0:  
        count += 1  
        number //= 10  

print(f"The number of digits is {count}.")  
#source code --> clcoding.com 

Wednesday, 27 November 2024

Day 6 : Python Program to Check prime number

 Python Program to Check prime number




num = int(input("Enter a number: "))

if num > 1:

    for i in range(2, num):
        if num % i == 0:
            print(f"{num} is not a prime number.")
            break
    else:
        print(f"{num} is a prime number.")
else:
    print(f"{num} is not a prime number.")

#source code --> clcoding.com 

Day 1- Python Program to check whether a given Nuber is Even or Odd using Recursion

 

def is_even(number):

    if number == 0:

        return True

    elif number == 1:

        return False

    else:

        return is_even(number - 2)


num = int(input("Enter a number: "))


if is_even(num):

    print(f"The number {num} is Even.")

else:

    print(f"The number {num} is Odd.")

    

#source code --> clcoding.com 


Day 3 : Python Program to Calculate Grade of a Student

 


def grade_student(marks):

    if marks >= 90:

        return "A"

    elif marks >= 80:

        return "B"

    elif marks >= 70:

        return "C"

    elif marks >= 60:

        return "D"

    elif marks >= 50:

        return "E"

    else:

        return "F"


marks = float(input("Enter the marks of the student: "))

grade = grade_student(marks)

print(f"The grade of the student is: {grade}")


#source code --> clcoding.com 

Tuesday, 26 November 2024

Day 2: Python Program to Check if a Number is a Palindrome

 


num = input("Enter a number: ")

if num == num[::-1]:

    print(f"{num} is a palindrome.")

else:

    print(f"{num} is not a palindrome.")

    

    #source code --> clcoding.com 

Popular Posts

Categories

100 Python Programs for Beginner (10) AI (33) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (156) C (77) C# (12) C++ (82) Course (67) Coursera (223) Cybersecurity (24) data management (11) Data Science (121) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (53) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (912) Python Coding Challenge (295) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses