Scripting Classroom Series- 23/Nov/2019

Reusability

  • How to make set of instructions written to be reused.

Find all the multiples of 3 below 100

  • Operator Set: + – * / % == <= >= < >
  • Solution 1
index = 1
muliple = 3
max = 100

until mulitple * index <= 100
  print mulitple * index
  index = index + 1
end

  • Solution in python
def multiples(multiple, max):
    index = 1
    while multiple * index <= max:
        print(multiple*index)
        index = index + 1

        
print("multiples of 3 till 100 are ")
multiples(3, 100)
print("multiples of 5 till 200 are ")
multiples(5, 200)
     
  • Debugging Hint:

    • Step Over : Execute the current statement and move to the next statement
    • Step Into : Get inside the function and execute from there
    • Breakpoint: Statement where the execution is stopped for manual debugging.
  • Each Python file is called as module.

  • Functions in one python module can be used in other python modules by importing modules.

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube