Beginer Learning 1

    0

    0

    Codiga Fan #25880

    - If a is larger then b, then the value of a will be added to the value of b and the result will be returned.

    Otherwise, the value of b will be added to a and the result will be returned.

    extends Sprite
    
    func _ready() -> void:
      operator(28)
      conditional(8)
      var result = add(6,5)
      print(result)
      
    func operator(b):
      var result = "I'm %d years old" % b 
      # %d means you're going to display it as a decimal integer.
      # %f would display it as a float number 
      print(result)
    func conditional (age):
      if age >=30:
      print("You're old")
      elif age < 30 and age >20:
      print("You're still young")
      else:
      print("you're a %d years old kid" %age)
    
    func add(a,b):
      var result = a +b
      return result  
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.