Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views6 pages

Denil Python Programs

The document contains a series of Python programs that demonstrate basic programming concepts such as swapping numbers, checking even or odd, determining positive/negative/zero, finding the largest of three numbers, summing digits, reversing a number, checking for palindromes, determining leap years, calculating factorials, and printing multiplication tables. Each program is accompanied by a brief explanation of its functionality. The author, Denilson Pinto B., mentions that he learned Python during his diploma and used these programs from ChatGPT for practice.

Uploaded by

thenewtech1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Denil Python Programs

The document contains a series of Python programs that demonstrate basic programming concepts such as swapping numbers, checking even or odd, determining positive/negative/zero, finding the largest of three numbers, summing digits, reversing a number, checking for palindromes, determining leap years, calculating factorials, and printing multiplication tables. Each program is accompanied by a brief explanation of its functionality. The author, Denilson Pinto B., mentions that he learned Python during his diploma and used these programs from ChatGPT for practice.

Uploaded by

thenewtech1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Q: Swap two numbers

#Program:

a=5

b = 10

a, b = b, a

print("a =", a, "b =", b)

Q: Check Even or Odd

#Program:

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

print("Even" if n % 2 == 0 else "Odd")


Q: Check Positive, Negative or Zero

#Program:

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

if n > 0:

print("Positive")

elif n < 0:

print("Negative")

else:

print("Zero")

Q: Find Largest of 3 Numbers

#Program:

a, b, c = 3, 7, 5

print("Largest is", max(a, b, c))


Q: Sum of Digits of a Number

#Program:

n = int(input("Enter number: "))

print("Sum of digits:", sum(int(d) for d in str(abs(n))))

Q: Reverse a Number

#Program:

n = int(input("Enter number: "))

print("Reversed:", int(str(abs(n))[::-1]) if n >= 0 else -int(str(-n)[::-1]))


Q: Check Palindrome (Number or String)

#Program:

s = input("Enter number or string: ")

print("Palindrome" if s == s[::-1] else "Not Palindrome")

Q: Check if a Year is Leap Year

#Program:

year = int(input("Enter year: "))

print("Leap Year" if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 else "Not Leap
Year")
Q: Factorial of a Number

#Program:

n = int(input("Enter number: "))

fact = 1

for i in range(1, n+1):

fact *= i

print("Factorial:", fact)

Q: Print Multiplication Table

#Program:

n = int(input("Enter number: "))

for i in range(1, 11):

print(f"{n} x {i} = {n*i}")


Sir I’m Denilson Pinto B. I have learned python in diploma so I have a used the programs
from Chatgpt.I understanded the programs myself and I tired in online complier

You might also like