<jupyter_start><jupyter_text>Functions- Function is a block of reusable code that is used to perform a specific action or task.- Advantages:    - Reducing duplication of code    - Decomposing complex problems into simpler pices    - Reuse of code    - improving the clarity of code    - information hiding - basically 2 types    - builtin functions    - user defined functions<jupyter_code>import builtins
dir(builtins)
a = 10
b = 34
c = 45
sum((a,b,c))
help(sum)
a = "apssdc"
max(a)
min(a)
ord("a")
chr(97)
abs(-45)
pow(4,5)
bin(13)
hex(13)
oct(13)<jupyter_output><empty_output><jupyter_text>- user defined function- it can be created by using def as a keyword<jupyter_code>def add():
    a = 4+6
    return a


add()
# positional arguments- pass in an order

def student(marks,name,rollnumber,phone):
    
    print(marks,name,rollnumber,phone)

student(23,"apssdc","18x41a145",256890073)
# keyword arguments

#key=value


def student(marks,name):
    print(marks,name)


student(name = "apssdc",marks = 90)
# default arguments

def default(a,b = "apssdc"):
    return a,b
default(7,"alekhya")
    

default("tpt")
# variable length arguments

def variable_length(*x):
    print(x)
variable_length(1,4,5,6,)
# keyword length arguments

def person(name,**kwlen):
    print(name)
    print(kwlen)
person(name = "alekhya",age = 21,place = "tpt",ph=57890356789)
# by using functions write a program wheather a  given number is even and odd number

def evenodd(a):
    if a%2==0:
        return True
    return False
evenodd(5)
def evenrange(a,b):#a=1,b=100
    for i in range(a,b+1):
        if evenodd(i):
            print(i,end=" ")
evenrange(int(input("enter starting value")),int(input("enter ending value")))
a = int(input("enter a value"))
type(a)
for i in range(int(input("enter table number")),int(input("enter ending table number"))):
    print("\n\nMULTIPLICATION TABLE FOR %d\n" %(i))
    for j in range(int(input("enter starting range")),int(input("enter ending range"))):
        print("%-5d X %5d = %5d" % (i, j, i*j))
# find the given number is prime or not

def isprime(a):#a=5
    c=0
    for i in range(1,a+1):
        if a%i==0:
            c+=1
    if c==2:
        return True
    return False
isprime(10)
            
            
# find primes with in the range
def range_primes(a,b):
    for i in range(a,b+1):
        if isprime(i):
            print(i,end = " ")
              
range_primes(int(input("enter the starting value")),int(input("enter the ending value")))
# convert decimal number to binary number
a = int(input("enter a number"))
x = bin(a)
print(x)
print(type(x))
# convert binary number to decimal number
int(x,2)
# find the index of a character "a"

a = "<NAME>"

for i in range(0,len(a)):
    if(a[i]=="a"):
        print("index number",i)
a ="abc"
len(a)
a[1]
# print sum of the given numbers into single digit

#input : 123   
#output : 6    
#input: 12345
# output:15--->6
n=int(input("Enter a number:"))
tot=0
while(n>0):
    dig=n%10
    tot=tot+dig
    n=n//10
print("The total sum of digits is:",tot)<jupyter_output>Enter a number:12345
The total sum of digits is: 15
{'fraction_non_alphanumeric': 0.1402439024390244, 'fraction_numerical': 0.03465982028241335, 'mean_word_length': 3.5973451327433628, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '245574', 'license': 'CC0-1.0', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1106, 'n_words': 332, 'path': 'Day07_14Dec2020/14-12-2020.ipynb', 'repo_name': 'AP-State-Skill-Development-Corporation/Programming-using-Python-MB10', 'size': '3124'}