# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/eunicemaravilla/midterms/blob/main/Control_Structure.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="o87Yuy_qSazu"
# <NAME>
#
# BSECE 2-2
#
#
# If Statement

# + colab={"base_uri": "https://localhost:8080/"} id="zcQG5yytSIiT" outputId="64670420-09bd-4176-e911-af4c25e99a4c"
a=12
b=100
if b>a:
  print("b is greater than a")

# + [markdown] id="FxFlOVf_Smgd"
# Elif Statement

# + colab={"base_uri": "https://localhost:8080/"} id="ZJ5bS-fySpt-" outputId="ddfcef3f-5134-47ec-c296-760a1360db84"
a=12
b=100
if b<a:
    print("b is less than a")
elif b>a:
    print("b is greater than a")

# + [markdown] id="FZNcin8PTM7m"
# Else Statement

# + colab={"base_uri": "https://localhost:8080/"} id="dLsX9ZWWSo1U" outputId="d28d052c-8e2e-497a-de73-75117aed7b21"
a=12
b=12
if b<a:
  print("b is less than a")
elif b>a:
  print("b is greater than a")
else:
  print("a is equal to b")

# + [markdown] id="Od6wQHDkTdP_"
# Short Hand If...Else

# + colab={"base_uri": "https://localhost:8080/"} id="M4kwtY9ZThaA" outputId="438631ca-b754-4d35-d7ad-38d79909b13a"
a=420
b=330
print("A") if a>b else print("B")

# + [markdown] id="RxJ9U7z3Tt1A"
# And condition

# + colab={"base_uri": "https://localhost:8080/"} id="w5QUzgScTvv_" outputId="5de2492e-474b-4c38-b922-c63e2b4e9fe1"
a=200
b=33
c=500
if a>b and a<c:
  print("Both conditions are true")

# + [markdown] id="rgi-82xST533"
# Or Condition

# + colab={"base_uri": "https://localhost:8080/"} id="VBH_7EjDT66a" outputId="4bff9116-6b44-416a-f410-39c55b11ec96"
a=200
b=33
c=500
if a>b or a<b:
  print("One of the conditions is True")

# + [markdown] id="P0ojEu6QUDKI"
# Nested If

# + colab={"base_uri": "https://localhost:8080/"} id="u0iSpV1YUGBY" outputId="94b52536-6973-4f62-a47f-1e8b31013f51"
x=11
if x>10:
  print("Above 10")
else:
  print("but not above 10")
if x>20:
  print("and also above 20!")
else:
  print("but not above 20")

# + [markdown] id="_bSIJSjtUdcJ"
# Nested if...Else

# + colab={"base_uri": "https://localhost:8080/"} id="yWwC4hb2UffB" outputId="5f75e1cf-8fe2-4687-f735-89a523c14ae4"
x=41
if x>10:
  print("Above 10")
if x>20:
  print("and also above 20!")
else:
  print("Below 10")

# + [markdown] id="-cZ08wz5Uti5"
# Example 1:
# Write a program that determines if the input age is qualified to vote or not the qualifying age is 18 old and above

# + colab={"base_uri": "https://localhost:8080/"} id="lHWLw-lOU1dZ" outputId="ba1531e3-0ae2-4d91-96b4-b941ce076e06"
x=9
print("You are qualified to vote")if x>=18 else print("You are unqualified to vote")
x=18

print("You are qualified to vote")if x>=18 else print("uYou are not qualified to vote")
x=20

print("You are qualified to vote")if x>=18 else print("You are not qualified to vote")


# + [markdown] id="RB8E4TdOVAjy"
# Example 2: 
# Write a program that determines if the input number is Positive or Negative. Consider 0 as positive(Considering that it contains no negative sign).

# + colab={"base_uri": "https://localhost:8080/"} id="vrjBjEdCUwuZ" outputId="9a6ba0cc-d850-423b-a7f5-5c936ea1a565"
number= int(input("Enter a number "))
if number >0:
  print("You entered a positive number")
elif number ==0:
  print("You entered zero")
else:
  print("You entered a negative number")


# + [markdown] id="GBhx_QVTVJei"
# Example 3: Write a program to determine if the grades are: if: grade>=75,"Passed" grade= 74,"Remedial" grade<74, "failed"

# + colab={"base_uri": "https://localhost:8080/"} id="KQ6_5Ao7VSsz" outputId="31441035-fa9d-470d-fe6f-4caa6fb37d0d"
number= int(input("Grade: "))
if number >=75:
  print("Passed")
elif number ==74:
  print("Remedial")
else:
  print("Failed")


StarcoderdataJupyterScriptsDedupFiltered