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
Remove All Duplicate Letters from a String in Python

input_str = "programming"
result = ""

for char in input_str:
if char not in result:
result += char

print("String after removing duplicates:", result)

Output:

String after removing duplicates: progamin


Explaination:- https://youtube.com/shorts/zZ1sXTIg2mg
Find the Longest Word in a Sentence

txt = "Python is a powerful language"

words = txt.split()
longest = max(words, key=len)

print("Longest word:", longest)




Output:

Longest word: powerful


Explaiantion:- https://www.youtube.com/shorts/GKFNSAueTS8
Check if a String is a Valid Palindrome After Removing Non-Alphanumeric Characters in Python

import re

txt = "A man, a plan, a canal: Panama"

clean = re.sub(r'[^a-zA-Z0-9]', '', txt).lower()

print(clean == clean[::-1])

Output:
True


Explaination:- https://www.youtube.com/shorts/rlO57Nw9tP4
Compress a String in Python


txt = "aaabb"
result = ""
count = 1

for i in range(len(txt)):
if i+1 < len(txt) and txt[i] == txt[i+1]:
count += 1
else:
result += txt[i] + str(count)
count = 1

print(result)


Output: a3b2

Explaination:- https://youtube.com/shorts/HcbYoxCOCRw
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