diff --git a/Built-in Functions-Binary Conversion.md b/Built-in Functions-Binary Conversion.md index bedea1b87..0a327fc86 100644 --- a/Built-in Functions-Binary Conversion.md +++ b/Built-in Functions-Binary Conversion.md @@ -10,8 +10,14 @@ To write a Python program to convert the number **16** into its **binary represe ## 🧾 Program -Add Code Here +``` +a=16 +print(bin(a)) +``` ## Output +image + ## Result +Thus, the program has been successfully executed. diff --git a/Functions: Modulo Calculator.md b/Functions: Modulo Calculator.md index d32881f06..8f121be7e 100644 --- a/Functions: Modulo Calculator.md +++ b/Functions: Modulo Calculator.md @@ -12,8 +12,21 @@ To write a Python program that defines a function which accepts two values and r ## 🧾 Program -Add code Here +``` +def result(a, b): + modulo_value = a % b + return modulo_value +a=int(input()) +b=int(input()) +print("modulo is", result(a, b)) +``` + ## Output +image + + ## Result + +The program to return two values modulo is successful. diff --git a/Lambda Function: Addition of Two Numbers.md b/Lambda Function: Addition of Two Numbers.md index 520cf0630..92927c359 100644 --- a/Lambda Function: Addition of Two Numbers.md +++ b/Lambda Function: Addition of Two Numbers.md @@ -9,8 +9,19 @@ 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()) +b=int(input()) +f=lambda a,b: a+b +print(f(a,b)) + +``` ## Output +image + + ## Result + +Thus, the program has been successfully executed. diff --git a/Looping(Patterns)-Pascal's Triangle Generator.md b/Looping(Patterns)-Pascal's Triangle Generator.md index 1a7dec6c3..25fd5c615 100644 --- a/Looping(Patterns)-Pascal's Triangle Generator.md +++ b/Looping(Patterns)-Pascal's Triangle Generator.md @@ -27,9 +27,28 @@ To write a Python program that generates **Pascal's Triangle** using numbers. Th --- ## 🧪 Program -Add Code Here + +``` +def factorial(n): + if n == 0 or n == 1: + return 1 + return n * factorial(n - 1) +def combination(n, k): + return factorial(n) // (factorial(k) * factorial(n - k)) +num_rows = int(input("Enter number of rows: ")) +for i in range(num_rows): + print(' ' * (num_rows - i - 1), end='') + for j in range(i + 1): + print(combination(i, j), end=' ') + print() +``` ## Sample Output +image + + ## Result +Thus, the program has been successfully executed + diff --git a/Loops-Palindrome Number check.md b/Loops-Palindrome Number check.md index 15dd6d692..4f1d45ca8 100644 --- a/Loops-Palindrome Number check.md +++ b/Loops-Palindrome Number check.md @@ -16,7 +16,31 @@ 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 + ## Result + +Thus, the program has been successfully executed .