Saturday, 20 June 2020

increase my python from 54 to 56% doing sQuare number in python


ok i have many more path to follow to finish my free course

and so that i can go over the free stuff too here

http://lifenstudy.blogspot.com/2020/06/free-stuff.html


where i am now... all theory part is finish and now the practical or project time


got 8 projects to complete towards the 90% completion. i am so near there... am i?


oops it not project but exercises   or latihan

Exercises (a.k.a Drill and Kill)




good luck to me....

Square a Number

Notes to Help You

  • Functions start with def
  • Don't forget your colons
  • Always return in functions rather than print!
Example Problem.
Write a function add_two that takes in two numbers as input and returns their sum.

how to do it......
got errors at first and lastly manage to solve it.
what a relief...

# Write a function to square_number that takes in a number and square it.



def square_number(number):
    
    return number * number




def test_square_number():
    assert square_number(2) == 4
    assert square_number(8) == 64
    assert square_number(10) == 100
    print(" YOUR code is correct !")
    
test_square_number()
print(square_number(2))
print(square_number(4))
print(square_number(8))
print(square_number(9))
print(square_number(10))


No comments: