Posts

Showing posts from August, 2018

Filter in Python

Image
Code Example ages = [5, 12, 17, 18, 24, 32] def myFunc(x):   if x < 18:        return False   else:        return True adults = filter(myFunc, ages) for x in adults:        print("You are Adult : ", x) Screenshot : Quiz Level 1 Quiz Level 2 Request Me

Argument Passing at Runtime in Python

Image
  Code # test.py import os import sys input_path = sys.argv[1] input_path1 = sys.argv[2] print(" \nYou Given : ", input_path, input_path1) > python test.py Kuntal Samanta Screenshot : Quiz Level 1 Quiz Level 2 Request Me

How To Use *args and **kwargs In Python

Image
Code Example # *args In Python def sum(x, y):     sum = x + y     print(sum) sum(1, 2)  Output: 3 sum(1, 2, 3)  Output: Here you will get "TypeError"  To solve this problem *args can help us, let's check it out : def sum( *args ):     sum = 0     for num in args:         sum += num     print("Sum is :", sum)   sum(1, 2) Output: 3 sum(1, 2, 3) Output: 6 sum(1, 2, 3, 4) Output: 10 Quiz Level 1 Quiz Level 2 Request Me