Scripting Foundation Series – Basic Terms 02/Nov

Scripting/Programming Essentials

  • For Programming we need majorly the following resources from OS
    • Processor
    • Memory (RAM)
  • Try to look at programming as speaking with some one who just understands basic arthimetic operations.
  • To solve problems we had discussed it is better to write psuedo codes/algorithmss
  • In this series lets understand basic terms.

DataType and Variables

  • Datatype is type of data, we use this get memory on RAM. This determines size in (bits/bytes)
  • Generally all the languages makes this simple by speaking terms which we understand
    • integer
    • decimal/float/double
    • boolean
  • Alias of memory location if the value in memory can be changed is Variable
  • Alias of memory location if the value in memory cannot be changed is constant
  • Lets read these lines
# C, C++, Java, C#
int age = 20;

# perl, shell
$age = 20

# python
age = 20
  • There are two kinds of Languages
    • Static Typed Languages
    • Dynamic Type Languages

Assignment

  • Allocating Value into memory using datatype/variable. Assignment is generally represented by operator =
age = 20

Operator

  • Operations supported by the language are called as opertors
  • Generally you would see classifications
    • Arthemetic Operators
    • Binary Operators
    • Text Operators

Exercise-1

  • Try to find whether given number is prime assuming the language which you are using has the following operators
+ => additon
- => subtraction
* => multiplication
/ => division
% => modulous
= => assignment
== => equality
!= => not equals

data type will be integer
  • Psuedo code of prime number
integer number = 7
integer index = 2
check: 
is number % index == 0 or index == number
if true then not prime exit program
if false increment index and go to step check:

print number is prime

exit:
  print number is not prime

Exercise-2

  • Try to find largest factor of the number assuming the language which you are using has the following operators
+ => additon
- => subtraction
* => multiplication
/ => division
% => modulous
= => assignment
== => equality
!= => not equals

data type will be integer
  • Sample Inputs and outputs
INput: 1000
500 is the largest factor

Input is 9
3 is the largest factor

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner