# data[].attributes.attachment_link.readable_text
n=int(input("Enter no"))
for i in range(n,0,-1):
    for j in range(i,0,-1):
        print(i,end='')
    print()

    

# data[].attributes.attachment_link.readable_text
m=int(input("no of rows"))
n=int(input("enter no of columns"))
for i in range(n,0,-1):
    for j in range(1,m):
        print(i,end='')
    print(i)

# data[].attributes.attachment_link.readable_text
m=int(input('Enter number of rows'))
n=int(input('Enter number of columns'))
for i in range(1,m+1):
    for j in range(n,0,-1):
        print(j,end='')
    print()

# data[].attributes.attachment_link.readable_text
#1.Sum of digits  2. Palindrome
def SumDigits():
    num=int(input("Enter your number: "))
    sum=0
    while num!=0:
        digit=num%10
        sum+=digit
        num=num//10
    print("The sum of digits is ",sum)
def Palindrome():
    num=int(input("Enter a number"))
    r=0
    n=num
    while num!=0:
        digit=num%10
        r=r*10+digit
        num=num//10
    if n==r:
        print("It is a palindrome number")
    else:
        print("It is not a palindrome number")
def main():
    print("1.Sum of digits")
    print("2.Palindrome")
    ch=int(input("Enter your choice: "))
    if ch==1:
        SumDigits()
    elif ch==2:
        Palindrome()
    else:
        print("Wrong choice")
main()
    

             

# data[].attributes.attachment_link.readable_text
def pallindrome():
    s=input("Enter a string")
    n=len(s)
    newstr=""
    for i in range(n-1,-1,-1):
        newstr+=s[i]
    if s==newstr:
        print("Palindrome")
    else:
        print("Not a palindrome")

def tuplesecond():
    t=eval(input("Enter tuple: "))
    high=max(t)
    sec_high=0
    for i in range(len(t)):
        if t[i]>sec_high and t[i]<high:
            sec_high=t[i]
    print("The second highest is ",sec_high)
    

def main():
    print("1.Check string pallindrome")
    print("2.2nd highest no in tuple")
    ch=int(input("Enter menu number"))
    if ch==1:
        pallindrome()
    elif ch==2:
        tuplesecond()
    else:
        print("Wrong Choice")
main()

# data[].attributes.attachment_link.readable_text
#1.Type of triangle 2.Highest and lowest no in list

def TypeTriangle():
    a=float(input("Enter the 1st side of triangle"))
    b=float(input("Enter the 2nd side of triangle"))
    c=float(input("Enter the 3rd side of triangle"))

    if a+b>c and b+c>a and c+a>b:
        print("It is a triangle")
        if a==b and b==c and c==a:
            print("Equilateral triangle")
        elif a==b or b==c or c==a:
            print("Isoscles Triangle")
        else:
            print("Scalene Triangle")
    else:
        print("It is not a triangle")

def highlowlist():
    list1=eval(input("Enter values: "))
    max=min=list1[0]
    for i in range(1,len(list1)):
        if list1[i]> max:
            max=list1[i]
        if list1[i]< min:
            min=list1[i]
    print("Highest element is ",max)
    print("Lowest element is ",min)

def main():
    print("1. Type of triangle")
    print("2. Highest and lowest no in list")
    ch=int(input("Enter your choice"))
    if ch==1:
        TypeTriangle()
    elif ch==2:
        highlowlist()
    else:
        print("Wrong choice")
main()

        

# data[].attributes.attachment_link.readable_text
def propercase():
    str1=input("Enter string:-")
    news=str1[0].upper()
    i=1

    while i<len(str1):
        if str1[i].isspace():
            news+=" "+str1[i+1].upper()
            i+=1
        else:
            news+=str1[i].lower()
            i=i+1
    print(news)
def switchcase():
    str=input("Enter a string: ")
    for ch in str:
        if ch.isupper():
            print(ch.lower(), end="")
        elif ch.islower():
            print(ch.upper(), end="")
        else:
            print(ch, end="")
        

def main():
    print("1.Lower to upper case")
    print("2.Propercase")
    ch=int(input("Enter menu number"))
    if ch==1:
        switchcase()
    elif ch==2:
        propercase()
    else:
        print("Wrong Choice")
main()

# data[].attributes.attachment_link.readable_text
def count():
    str=input("Enter a string: ")
    alphacnt=digitcnt=spacecnt=symcnt=0
    for ch in str:
        if ch.isalpha():
            alphacnt+=1
        elif ch.isdigit():
            digitcnt+=1
        elif ch.isspace():
            spacecnt+=1
        else:
            symcnt+=1
print("The no of alphabets are:",alphacnt)
print("The no of digits are:",digitcnt)
print("The no of spaces are:",spacecnt)
print("The no of symbols are:",symcnt)
print("The no of words are:",spacecnt+1)

def reverselist():
    list1=eval(input("Enter list: "))
    n=len(list1)
    for i in range(0,n//2):
        list1[i],list1[n-1-i] = list1[n-1-i],list1[i]
    print(list1)
    
def main():
    print("1.Reverse list")
    print("2.Count no of alphabets,digits,space,symbol and words")
    ch=int(input("Enter menu number"))
    if ch==1:
        reverselist()
    elif ch==2:
        count()
    else:
        print("Wrong Choice")
main()

# data[].attributes.attachment_link.readable_text
#1. Sum,average of list  2. Root type of quadratic eqn

def sumaveragelist():
    list1=eval(input("Enter a list"))
    s=0
    for i in range(len(list1)):
        s+=list1[i]
    print("The sum is: ",s)
    print("The average is: ",s/len(list1))

def rootquadratic():
    A=int(input("Enter coefficient A"))
    B=int(input("Enter coefficient B"))
    C=int(input("Enter coefficient C"))

    D=(B**2)-(4*A*C)
    P=(-B+(D**0.5))/(2*A)
    Q=(-B+(D**0.5))/(2*A)

    if D<0:
        print("The root are not real")
    elif D=0:
        print("The roots are ",P,"and ",Q)
        print("They are real and equal")
    else:
        print("The roots are ",P,"and ",Q)
        print("They are real and distinct")
def main():
    print("1.Sum and average of list")
    print("2.Root type of quadratic eqn")
    ch=int(input("Enter menu number"))
    if ch==1:
        sumaveragelist()
    elif ch==2:
        rootquadratic()
    else:
        print("Wrong Choice")
main()

        
    

# data[].attributes.attachment_link.readable_text
# 1.Prime number 2.Armstrong number

def PrimeNumber():
    n=int(input("Enter the number"))
    a=0
    if n>1:
        for i in range(1,n//2):
            if n%i==0:
                a+=1
        if a>1:
            print("Composite")
        else:
            print("Prime")
    else:
        print("The number is neither prime nor composite")

def ArmstrongNumber():
    num=int(input("Enter a number"))
    r=0
    n=num
    while num!=0:
        digit=num%10
        r=r+digit**3
        num=num//10
    if r==n:
        print("It is an armstrong number")
    else:
        print("It is not an armstrong number")

def main():
    print("1.Prime number")
    print("2.Armstrong number")
    ch=int(input("Enter menu number"))
    if ch==1:
        PrimeNumber()
    elif ch==2:
        ArmstrongNumber()
    else:
        print("Wrong Choice")
main()

# data[].attributes.attachment_link.readable_text
#1.Perfect no  2.Fibanacci
def PerfectNo():
    n=int(input("Enter the value of number"))
    s=0
    for i in range(1,n+1):
        if n%i==0:
            s=s+i
    if s==2*i:
        print("The no is a perfect no")
    else:
        print("The no is not a perfect number")
def Fibanacci():
    n=int(input("Enter no of terms:"))
    t1=0
    t2=1
    if n==1:
        print(t1,end=",")
    else:
        print(t1,t2,end=",")
        for i in range(3,n+1):
            t3=t1+t2
            print(t3,end="")
            t1=t2
            t2=t3
def main():
    print("1. Perfect no")
    print("2. Fibonacci series")
    ch=int(input("Enter your choice"))
    if ch==1:
        PerfectNo()
    elif ch==2:
        Fibanacci()
    else:
        print("Wrong choice")
main()

# data[].attributes.attachment_link.readable_text
student=dict()
while True:
    print("1.Insert record")
    print("2.Delete record")
    print("3.Edit record")
    print("4.Display")
    print("5.Search")
    print("6.Exit")

    ch=int(input("Enter choice: "))
    if ch==1:
        n=int(input("No of students: "))
        for i in range(n):
            id=int(input("Enter id"))
            name=input("Enter name")
            student[id]=name
    elif ch==2:
        id_delete=int(input("Enter id to be deleted"))
        x=student.pop(id_delete,"none")
        if x=="none":
            print("Id not found")
        else:
            print("Id deleted")
    elif ch==3:
        id_edit=int(input("Enter id to be modified"))
        if id_edit in student.keys():
            student[id_edit]=input("Enter name")
        else:
            print("Id does not exist")
    elif ch==4:
        print("ID\tName")
        id=student.keys()
        for x in id:
            print(x,"\t",student[x])
    elif ch==5:
        id_search=int(input("Enter id"))
        a=student.get(id_search,"none")
        if a=="none":
            print("Id does not exist")
        else:
            print("Name of student is ",a)
    elif ch==6:
        exit()
    else:
        print("Wrong choice")
            

# data[].attributes.attachment_link.readable_text

def adjacentelements():
    list1=eval(input("Enter the list"))
    n=len(list1)
    for i in range(0,n-1,2):
        list1[i], list1[i+1] = list1[i+1], list1[i]
    print(list1)

def swaphalfelements():
    list1=eval(input("Enter list"))
    n=len(list1)
    for i in range(0,n//2):
        list1[i],list1[(n+1)//2+i] = list1[(n+1)//2+i] ,list1[i]
    print(list1)

def main():
    print("1.Swap adjacent elements in list")
    print("2.Swap 1st half with 2nd half of list")
    ch=int(input("Enter menu number"))
    if ch==1:
        adjacentelements()
    elif ch==2:
        swaphalfelements()
    else:
        print("Wrong Choice")
main()
