Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Built-in Functions-Binary Conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ To write a Python program to convert the number **16** into its **binary represe

## 🧾 Program

Add Code Here
```
a = 16
b = bin(a)
print("Binary representation of", a, "is", b)
```

## Output

<img width="517" height="202" alt="image" src="https://github.com/user-attachments/assets/513011e1-303b-4f63-bac7-382d7b177b07" />

## Result

Hence, the code is executed successfully, and the number **16** is converted into its **binary representation** `0b10000` using the built-in `bin()` function.
13 changes: 12 additions & 1 deletion Functions: Modulo Calculator.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@ To write a Python program that defines a function which accepts two values and r
5. Call the `result` function with the user-provided values.

## 🧾 Program
```
def result(a, b):
print("Modulo:", a % b)

Add code Here
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
result(num1, num2)
```

## Output

<img width="631" height="411" alt="image" src="https://github.com/user-attachments/assets/d613c803-c73f-4871-a537-6800cd93c92e" />


## Result

Hence, the code is executed successfully, and the function correctly computes and displays the **modulo** of the two input numbers.
14 changes: 13 additions & 1 deletion Lambda Function: Addition of Two Numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ To write a Python program that defines a **lambda function** which takes two arg
3. Call the function with the user inputs and print the result.

## 🧾 Program
Add code here
```
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

f = lambda x, y: x + y
result = f(a, b)

print("Sum:", result)
```

## Output

<img width="482" height="222" alt="image" src="https://github.com/user-attachments/assets/20bacc6a-994a-4947-a65b-c4d60c725d8b" />

## Result

Hence, the code is executed successfully, and the **lambda function** correctly computes and displays the sum of the two input numbers.
15 changes: 14 additions & 1 deletion Looping(Patterns)-Pascal's Triangle Generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,22 @@ To write a Python program that generates **Pascal's Triangle** using numbers. Th
---

## 🧪 Program
Add Code Here
```
from math import factorial

rows = int(input("Enter number of rows: "))

for i in range(rows):
print(" " * (rows - i), end="")
for j in range(i + 1):
print(factorial(i) // (factorial(j) * factorial(i - j)), end=" ")
print()
```

## Sample Output

<img width="376" height="255" alt="image" src="https://github.com/user-attachments/assets/5295362f-a2e7-46d7-8daa-213299287048" />

## Result

Hence, the code is executed successfully, and the Pascal’s Triangle is generated correctly for the user-specified number of rows.
19 changes: 18 additions & 1 deletion Loops-Palindrome Number check.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ To write a Python program that checks whether a given number is a **palindrome**
- Else, print that it is not a palindrome.

## 🧾 Program
Add code Here
```
num = int(input("Enter a number: "))
temp = num
rev = 0

while temp > 0:
rev = (10 * rev) + temp % 10
temp = temp // 10

if rev == num:
print(num, "is a palindrome")
else:
print(num, "is not a palindrome")
```
## Output

<img width="400" height="237" alt="image" src="https://github.com/user-attachments/assets/3616fbce-880d-4b6d-9e58-099ca890738a" />

## Result

Hence, the code is executed successfully, and the program correctly checks whether the entered number is a palindrome.