Scripting Classroomnotes 02/Dec/2022

Scripting vs Programming

  • Scripting
    • We directly execute code and code is interpreted line by line
    • We use scripting to automate or build small utilities
  • Programming
    • Program needs to be compiled.
    • We tend to solve problems/build applications

Scripting/Programming Basics Contd

  • Execution of script/program happens line by line
  • Consider the following problem
    • user gives you url as input, you need to print the domain name
    • user should be shown error if the input is not in https or http url format
  • Solution:
    1. Remember input provided as url url = 'https://qt.com/test'
    2. is url in the http url format and remember as result
    3. print domain if result is true
    4. enter the url in the right format if the result is false
  • THis script will have two possibities in its execution
    • 1,2,3
    • 1,2,4
  • Generally the above way is referred as conditional execution.
  • Consider the following problem
    • user enters number and you need to print all the numbers below that number till 0
  • Solution:
    1. Remember input provide as number
    2. Start from index = 0
    3. print index
    4. add 1 to the index
    5. check if it is less than number and remeber as result
    6. if result is true
    7. go to step 3
    8. else stop
  • The above approach is called as looping constructs

Character Introduction

  • ELSA
  • What she knows ?
    • Rememebering values
    • + - * / %
    • =
    • <=, >=, ==
  • You can instruct her what has to be done in steps and she can do it faster and also repeat this multiple times.

Instruction Manual with ELSA

  • Examples 1: Calculate GST (7%)
1. Remember input provided as price
2. calculate price * 7 / 100 and remember as gst
3. say gst
  • Examples 2: Calculate electricity assuming till 300 units the bill will be zero any thing above 300 price per unit is 7 rs
1. Rember input provided as units
2. units = units - 300
3. if units < 0 
4.    units = 0
5. say units * 7


Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%