Python Editor

Python | Lesson2 | For Loops


#For loos iterates over a sequence of Lists, Tuples, Strings

countries = ["USA", "UK", "Mexico"]
for country in countries:
  print(country)

4 comments:

  1. def add (x,y):
    "This function adds two numbers"
    return x+y


    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))

    print("sum of num1, num2 =", add(num1, num2))

    ReplyDelete
  2. def add (x,y):
    "This function adds two numbers"
    return x+y

    def subtract (x,y):
    "This function subtracts two numbers"
    return x-y

    def multiply (x,y):
    "This function multiplies two numbers"


    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))

    print("of num1, num2 =", add(num1, num2))
    print("multiplication of num1, num2=", multiply(num1, num2))

    ReplyDelete
  3. ef divide (x,y):
    "This function divides two numbers"


    num1 = float(input("Enter first number"))
    num2 - float(input( "Enter seond number"))

    print("of num1, num2 =", divide(num1, num2))
    print(division of num1, num2=", divide(num1, num2"))

    ReplyDelete
  4. def add (x,y):
    "This function adds two numbers"
    return x+y

    def subtract (x,y):
    "This function subtracts two numbers"
    return x-y

    def multiply (x,y):
    "This function multiplies two numbers"
    return x*y


    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))

    print("of num1, num2 =", add(num1, num2))
    print("multiplication of num1, num2=", multiply(num1, num2))
    print("subtraction of num1, num2=", subtract (num1, num2))

    def divide (x,y):
    "This function divides two numbers"
    return x/y


    num1 = float(input("Enter first number"))
    num2 - float(input( "Enter seond number"))

    print("of num1, num2 =", divide(num1, num2))
    print("division of num1, num2=", divide(num1, num2))

    ReplyDelete