×

Challenges

  1. Not started

  2. Not started

  3. Not started

  4. Not started

  5. Not started

  6. Not started

  7. Not started

  8. Not started

  9. Not started

  10. Not started

  11. Not started

  12. Not started

  13. Not started

  14. Not started

  15. Not started

  16. Not started

  17. Not started

  18. Not started

  19. Not started

  20. Not started

  21. Not started

Challenge 1.2

Whakaaturia ngā Nama Tāhūrua (whakamahia tētahi taurangi)

Taumata Wero: Kākano

Herenga:

Waihangatia tētahi papatono ki te whakaatu i ngā nama 1, 2, 4, 8 me te 16 i runga i te mata, kotahi te nama ia wā. Kaua e whakaatu noa i te nama, rokirokia ki roto i tētahi taurangi, ā, whakaaturia te taurangi.

Tīwhiri
  • Hangaia tētahi taurangi, e kīia ana ko kaute_tongi panonitia tōna uara ki te 1, 2, 4, 8, 16 hoki. Tūturu me whai tikanga te ingoa o te taurangi, kia ngāwari ai te pānui mā tangata kē. I te tauira kei runga nei, ka tapaina te taurangi ko te kaute_tongi nā te mea ka mau te kaute o ngā tongi kei runga i tētahi kāri.
  • Whakamahia kaute_tongi = 0 ki te tautuhi i te uara mō tō taurangi hou. Mā tēnei waehere e whakatau ai te kaute_tongi ki te kore.
  • Mā te tauākī print() e āhei ai koe te whakaatu i ngā kōrero, ngā uara rānei o roto i ngā taiapa kei runga i te mata. Hei tauira: mā te print(100) e whakaatu ai te 100 i runga i te mata.
  • Me whakamahi e koe te tauākī print() mō ia nama e pīrangi ana koe ki te whakaatu.
Programming Reminders
# Print a string directly
print("Hello World!")

# Print a variable
print(my_var)

Variables

# Set a variable as a string
fruit_name = "Apple"

# Set a variable as an integer 
pieces_of_fruit = 7

# Set a variable from a calculation
cost_of_fruit = pieces_of_fruit * cost_per_item

# Add one to a value
pieces_of_fruit += 1

Conditionals

# Find out the discount on fruit
if pieces_of_fruit > 100:
   print("Bulk discount applies")
elif pieces_of_fruit > 5:
   print("Discount applies")
else:
   print("No discount")

For loops

# Print numbers 0-9 - remember Python starts counting from 0 
for num in range(10):
    print(num)

While loops

# Print numbers 0-9 using a while loop and a variable
num = 0
while num < 10:
    print(num)

    # Increment the variable by one.
    # It will prevent an infinite loop!
    num += 1 

Lists

# Create a list of fruit 
fruit = ["Apple", "Banana", "Orange", "Pear"]

Functions

# Create a function which prints a greeting
def greeting(name):
    print("Hello " + name)

# Call the function
greeting("Spiderman")

Enter your code in the editor below

Your results will be displayed here

Input Expected output Received output Status

                
1
2
4
8
16

                
Not yet run ?

Challenge 2 of 21