Skip to main content

PyThon - Code



\...CODE.../

---------------------------------------------------------------

def main():

    x = int(input("What is x? " ))
    print("x squared is ", square(x))

def square(n):
    return n*n
main()

---------------------------------------------------------------

def main():
    x = int(input("What is X? "))

    if is_even(x):
        print("Even")
    else:
        print("Odd")

def is_even(n):
    if n % 2 ==0:
        return True
    else:
        return False
#   return True if n % 2 == 0 else False #orrrr
#   return n % 2 == 0 #orrrrrrr

main()

---------------------------------------------------------------

name = input("What is Your Name : ")

name = name.title()
match name:

    case "Shailesh" | "Kusum" | "Parth":
        print("Hello, " + name + "! You live in Naiya - 1.")
    case "Ketan" | "Nirali" | "Aarohi":
         print("Hello, " + name + "! You live in Dev Samrudhi.")
    case "Suresh" | "Sarmi" | "Kaushik":
        print("Hello, " + name + "! You live in Pryosha Paradise.")
    case _:
        print("Hello, " + name + "! Sorry, But Your residence is unknown.")

---------------------------------------------------------------
---------------------------------------------------------------
---------------------------------------------------------------
---------------------------------------------------------------
---------------------------------------------------------------

Comments

Popular Posts

Web Applications

PyThon - Notes