diff --git a/Built-in Functions-Binary Conversion.md b/Built-in Functions-Binary Conversion.md index bedea1b87..dc5ea20f9 100644 --- a/Built-in Functions-Binary Conversion.md +++ b/Built-in Functions-Binary Conversion.md @@ -9,9 +9,16 @@ To write a Python program to convert the number **16** into its **binary represe 3. Print the result. ## 🧾 Program +``` +x=16 +y=bin(x) +print(y) +``` + -Add Code Here ## Output +![image](https://github.com/user-attachments/assets/eb21d0cf-f113-4233-b719-2318653f5522) ## Result +Thus the python program is executed successfully diff --git a/Functions: Modulo Calculator.md b/Functions: Modulo Calculator.md index d32881f06..0ffcb0072 100644 --- a/Functions: Modulo Calculator.md +++ b/Functions: Modulo Calculator.md @@ -11,9 +11,22 @@ 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): + modulo_value = a % b + return modulo_value + +a=int(input()) +b=int(input()) +print("modulo is", result(a, b)) +``` + + -Add code Here ## Output +![image](https://github.com/user-attachments/assets/16d5e049-3c09-42cb-83be-c261ebd7dc66) + ## Result +Thus the python code is executed successfully diff --git a/Lambda Function: Addition of Two Numbers.md b/Lambda Function: Addition of Two Numbers.md index 520cf0630..96619d0ae 100644 --- a/Lambda Function: Addition of Two Numbers.md +++ b/Lambda Function: Addition of Two Numbers.md @@ -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 +``` +i=int(input()) +j=int(input()) +z=int(input()) + +f = lambda a, b,c: a+b+c + +print(f(i, j,z)) +``` ## Output +![image](https://github.com/user-attachments/assets/c67311de-5870-42b4-94bb-1b4c2fb0c356) + ## Result + +Thus,the Python program that defines a lambda function which takes two arguments a and b, and returns their sum is created successfully. diff --git a/Looping(Patterns)-Pascal's Triangle Generator.md b/Looping(Patterns)-Pascal's Triangle Generator.md index 1a7dec6c3..427032896 100644 --- a/Looping(Patterns)-Pascal's Triangle Generator.md +++ b/Looping(Patterns)-Pascal's Triangle Generator.md @@ -9,7 +9,6 @@ This project demonstrates a simple Python program to generate **Pascal’s Trian To write a Python program that generates **Pascal's Triangle** using numbers. The number of rows is accepted from the user. --- - ## 🧠 Algorithm 1. Start the program. @@ -27,9 +26,25 @@ To write a Python program that generates **Pascal's Triangle** using numbers. Th --- ## 🧪 Program -Add Code Here +``` +rows = int(input()) +coef = 1 + +for i in range(1, rows+1): + for space in range(1, rows-i+1): + print(" ",end="") + for j in range(0, i): + if j==0 or i==0: + coef = 1 + else: + coef = coef * (i - j)//j + print(coef, end = " ") + print() +``` ## Sample Output +![image](https://github.com/user-attachments/assets/ab54bf71-edb9-4b6a-ab47-ab7b2729b979) -## Result +## Result +Thus,the Python program that generates Pascal's Triangle using numbers. The number of rows is accepted from the user is created successfully. diff --git a/Loops-Palindrome Number check.md b/Loops-Palindrome Number check.md index 15dd6d692..9f2178bbc 100644 --- a/Loops-Palindrome Number check.md +++ b/Loops-Palindrome Number check.md @@ -16,7 +16,23 @@ 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()) +rev=0 +temp=num +while temp>0: + rev=(10*rev)+temp%10 + temp//=10 +if rev==num: + print("The given number {} is a Palindrome".format(num)) +else: + print("The given number {} is not a palindrome".format(num)) +``` + ## Output +![image](https://github.com/user-attachments/assets/d3b890b8-34d1-48a7-ab16-25c77ee68436) + ## Result +Thus,the Python program that checks whether a given number is a palindrome using loops is created successfully. +