Code Zone Telugu
15 subscribers
60 links
Code Zone Telugu
Learn coding in Telugu!
Get tips, tutorials, and tech updates on Python, Java, JS etc..
Download Telegram
Find Maximum Digit in a Number Without Built in Function


num = 59284
max_digit = 0

while num > 0:
digit = num % 10
if digit > max_digit:
max_digit = digit
num = num // 10

print(max_digit)

Output: 9

Explaination:- https://youtube.com/shorts/xjZfaV7Xdjk
Find GCD of Two Numbers in Python

import math

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

result = math.gcd(a, b)
print("GCD of", a, "and", b, "is:", result)


Output
Input → 12, 18
GCD of 12 and 18 is: 6



Explaination:- https://youtube.com/shorts/QGd32oNoz6k
Find LCM of Two Numbers in Python

import math

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

gcd = math.gcd(a, b)
lcm = (a * b) // gcd

print("LCM of", a, "and", b, "is:", lcm)


Output
Input → 12, 18
LCM of 12 and 18 is: 36


Explaination:- https://youtube.com/shorts/N17ktpEOMoI
Check Whether a Number is Palindrome or Not

num = 121
temp = num
rev = 0

while num > 0:
digit = num % 10
rev = rev * 10 + digit
num = num // 10

if temp == rev:
print("Palindrome")
else:
print("Not Palindrome")


Output
Input → 121 → Palindrome
Input → 123 → Not Palindrome


Explaination:- https://youtube.com/shorts/Aql1suBSlys
Find Square & Cube of Number | Python

num = 5

square = num ** 2
cube = num ** 3

print("Square:", square)
print("Cube:", cube)

Output
Input → 5
Square: 25
Cube: 125


Explaination:- https://youtube.com/shorts/bXydwbsH5eY
Calculate the Average of N Numbers

n = int(input("How many numbers? "))

numbers = []
for i in range(n):
num = float(input("Enter number: "))
numbers.append(num)

total = sum(numbers)
average = total / n

print("Average =", average)

Output
Input → 5 numbers: 10, 20, 30, 40, 50
Average = 30.0

Explaination:- https://youtube.com/shorts/g3ddbmTOyBk
Convert a Decimal Number to Binary

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

binary = bin(num)
print("Binary with prefix:", binary)
print("Binary without prefix:", binary[2:])

Output
Input → 10
Binary with prefix: 0b1010
Binary without prefix: 1010

Explaination:- https://youtube.com/shorts/ExCnEOeiRoM
Day 3 - Convert Binary to Decimal in Just 1 Minute!

def binary_to_decimal(binary_str):
decimal = 0
power = len(binary_str) - 1
for digit in binary_str:
decimal += int(digit) * (2 ** power)
power -= 1
return decimal

print(binary_to_decimal("1010")) # 10
print(binary_to_decimal("1111")) # 15


Output
Input → "1010" → Output → 10
Input → "1111" → Output → 15


Explaination:- https://youtube.com/shorts/b6t5G9AV71w
Day 4 - Convert Octal to Decimal in Just 1 Minute!

def octal_to_decimal(octal_str):
decimal = 0
power = len(octal_str) - 1
for digit in octal_str:
decimal += int(digit) * (8 ** power)
power -= 1
return decimal

print(octal_to_decimal("12")) # 10
print(octal_to_decimal("77")) # 63


Output
Input → "12" → Output → 10
Input → "77" → Output → 63


Explaination:- https://youtube.com/shorts/2uqOZSl40Ms
Day 5 - Sum of All Elements in a Matrix

def matrix_sum(matrix):
total = 0
for row in matrix:
for element in row:
total += element
return total

# Example
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(matrix_sum(matrix)) # 45


Output
Input → [[1,2,3],[4,5,6],[7,8,9]]
Output → 45


Explaination:- https://youtube.com/shorts/sediRwo9SgE
Day 6 - Count Vowels and Consonants in a String

def count_vowels_consonants(text):
vowels = "aeiou"
v_count = 0
c_count = 0

for char in text.lower():
if char in vowels:
v_count += 1
elif char.isalpha():
c_count += 1

return v_count, c_count

text = input("Enter a text: ")
v, c = count_vowels_consonants(text)
print("Vowels:", v)
print("Consonants:", c)


Output
Input → Hello World
Vowels: 3
Consonants: 7


Explaination:- https://youtube.com/shorts/HhYb_mDR5Js
Day 7 - Remove Vowels from a String

def remove_vowels(text):
vowels = "aeiouAEIOU"
result = ""
for char in text:
if char not in vowels:
result += char
return result

print(remove_vowels("Hello World"))


Output
Input → Hello World
Output → Hll Wrld

Explaination:- https://youtube.com/shorts/dyVn8hwiFLQ
Day 8 - Check Whether a Number is Armstrong or not

def is_armstrong(num):
digits = [int(d) for d in str(num)]
power = len(digits)
return sum(d ** power for d in digits) == num

print(is_armstrong(153)) # True
print(is_armstrong(123)) # False


Output
Input → 153
True
Input → 123
False

Explaination:- https://youtube.com/shorts/KpLZNPkGc2M
Day 9 - Calculate Power of a Number

def power(x, y):
result = 1
for _ in range(y):
result *= x
return result

print(power(2, 3)) # 8
print(power(5, 2)) # 25


Output
Input → 2 3
Output → 8

Input → 5 2
Output → 25

Explaination:- https://youtube.com/shorts/0IENdrRgI-M
Day 10 - Check Whether a Number is Perfect or Not

def is_perfect_number(num):
if num <= 1:
return False
divisors_sum = 0
for i in range(1, num):
if num % i == 0:
divisors_sum += i
return divisors_sum == num

print(is_perfect_number(6)) # True
print(is_perfect_number(28)) # True
print(is_perfect_number(12)) # False


Output
Input → 6
Output → True

Input → 28
Output → True

Input → 12
Output → False

Explaination:- https://youtube.com/shorts/WTQr72jBICM