C, C++, Java, Python, PHP, JavaScript and Linux For Beginners
C, C++, Java, Python, PHP, JavaScript and Linux For Beginners
− Socrates
Manjunath.R
*Email: [email protected]
Disclaimer
Despite my best efforts to assure the accuracy of the material in this book, I do not accept
and hereby disclaim any liability to any party for any loss, damage, or disruption caused by
mistakes or omissions, whether caused by negligence, accident, or any other cause.
As long as you comply by the conditions of the license, the licensor cannot revoke these rights.
You have to
I dedicate this book to every individual, programmer, teacher, educational institutions and
enterprise corporations in every country of the world for their immense contributions towards the
process of creating, designing, deploying and supporting software…
Acknowledgements
Without the amazing work of some renowned programmers, their creativity, and their inventiveness in the
field of software programming, this book would not have been accomplished. I would like to use this
opportunity to thank my dearest friend and well-wisher "Lawrence" for his unwavering support during
the COVID crisis and for giving me access to all the resources I needed to finish this book. I want to
express my gratitude to my family for their support and encouragement as I wrote this book, especially to
my mother, who has been a tremendous source of inspiration in my life. I owe a lot of gratitude to my
mother for teaching me how to be perseverant and strong in life. Finally, I want to emphasize how crucial
patience is when writing a book or taking on any other project in life.
Foreword
I'm neither the proprietor of a well-known publishing house or a top IT firm with hundreds of in-
house programmers who could easily produce anything I needed. I am a self-employed software
engineer who is passionate about what I do, and believe me when I say that a lot of work and
effort went into compiling this comprehensive edition. I'll be overjoyed if it helps even a few
others reach their ideal positions in their professions.
Thank You
− Manjunath.R
An Enjoyable Introduction to Coding
Introduction
Today's devices are mostly powered by software: almost everyone uses Facebook,
WhatsApp and Twitter to communicate, many phones have internet-connected desktops, and the
majority of office work requires using a computer to do tasks. As a response, there is a huge
increase in demand for programmers. Numerous books, interactive websites, and programmer
training courses make the bold claim that they can turn ambitious novices into software
engineers earning six figures. This book is for all programmers, whether you are a novice or an
experienced pro. Its numerous examples and well paced discussions will be especially beneficial
for beginners. Those who are already experienced with programming will probably gain more
from this book, of course. You will be at a modest level of programming proficiency when you
have finished this book, from where you can take yourself to next levels so that you can
automate simple tasks such as:
This book will make an amazing complement to any tutorial and serve as a source of information
to your specific inquiries if you are just learning what kind of animals C, C+ +, Java, PHP,
Python, and JavaScript are. Even if your career has nothing to do with computers, the skills you
learn from programming can be valuable at school and at work. Programming is a pleasant,
occasionally difficult and perhaps frustrating activity. Creativity, logic, and problem-solving are
all enhanced through programming.
As you progress through this book, keep in mind that programming can be enjoyable. Do not
consider of this as work. Consider programming as a means to develop entertaining games or
software applications that you can show off to others or your friends. Programming is a
tremendous brain workout and is essential today because so much of our everyday world is
automated. But above all, you have access to the quick-paced, creative world that depends on
machine connections.
"The only way to learn a new programming language is by writing programs in it."
– Dennis Ritchie
Note:
1. Always be aware of the purpose of your software program before beginning to write it.
2. Programming is not the solution; it is merely a means to achieve a solution.
3. Consider the problem rather than just the solution.
4. Always try to make things simpler; anyone can come up with a complicated answer to a
problem. To make a solution simple while remaining consistent, it requires extra work
and consideration.
5. Reduce Deeply Nested Ifs or Loops: When your software program is deeply nested, your
program becomes complicated and disorganized.
6. Delete Unnecessary Code. Make sure your software program is safe, secure, reliable,
testable and clear to read.
7. Give code reviews some attention so you can spot bugs early, before they cause serious
problems in your software application.
8. Reduce complexity. Software programs must have clear explanations.
9. Generalize your software program. Make sure your software program is documented.
Understanding the function of a certain component of the software application is greatly
aided by the documentation and comments.
10. Fancy algorithms and data structures are more difficult to implement. Use simple,
efficient, appropriate algorithms and data structures.
11. Refractor your software program frequently to improve its internal software attributes in
terms of upkeep, testing and comprehension.
12. Each time you make a change to your software program: check it, build it and test it.
13. Before being released, all software codes must pass each and every unit test.
14. Always use caution when using someone else's code. Maintain a standardized, orderly
and generally consistent coding style.
15. Avoid implementing a code style that is too hard to understand.
16. Because it makes the code more difficult to maintain, duplication is seen adversely in
software programming.
17. Look for bugs and flaws and fix them. Divide your software program into Brief, Concise
Units.
18. Avoid overdesigning. Focus your software design on the requirements of the clients.
19. Program defensively. Functions should be simple and do a distinct, defined task.
20. Create reusable functions and Keep the functions as simple, immutable and manageable
as possible.
21. When naming your variables and functions, choose names that are meaningful and
descriptive.
22. Put your software program's structure on view by using indentation.
23. Delete any unused variables and functions; do not comment them.
24. If you feel that a part of the software program is excessively unorganized, regroup and
modify it, or even split it up into different portions.
25. Avoid using GOTO statements because they cause the software program to be
unstructured, which makes it harder to understand and makes debugging more complex.
26. Avoid using the same identifier more than once.
27. The length of functions shouldn't be excessively long.
28. Think Twice, Code Once: Encourage yourself to consider the problem more before
coming up with a solution.
29. The very first step in making a software program readable by humans is to add
comments. Comments should be detailed explanations of a software program.
30. White space should be utilized regularly to increase code readability even though it has
little significance to compilers.
31. Coding standards must be followed while formatting code.
32. Avoid security pitfalls and Keep your software code portable.
33. All software design is redesign. Take advice from others' experience.
34. The writing of software program should make it simple for a future software developer
to correct errors or modify its functionality.
35. Never compromise clarity for a false sense of efficiency.
"More computing sins are committed in the name of efficiency (without necessarily
achieving it) than for any other single reason − including blind stupidity."
− W.A. Wulf
36. Enhance the appearance of software program by avoiding excessively long names or
ambiguous acronyms
37. Look for a method that employs a loop rather than duplicating lines. Compared to 100
individual blocks of code, one loop that can handle 100 repetitions is simpler to debug.
You're not coding to amaze strangers. You're in this
profession to find ways to resolve problems.
"The computer programmer is a creator of universes for which he alone is the lawgiver. No playwright,
no stage director, no emperor, however powerful, has ever exercised such absolute authority to arrange a
stage or field of battle and to command such unswervingly dutiful actors or troops."
− Joseph Weizenbaum
Top 10 Programming Languages and Their Applications
A skilled coder can identify the best solution to any problem and solve even the most challenging
issues. Being a good programmer requires constant knowledge upkeep and the acquisition of
new skills. A PhD isn't always necessary to become a skilled programmer, but discipline and
determination are. Being a successful programmer demands you to be one step ahead, while
becoming a respectable coder takes years of hard effort.
Image Credit: Wikipedia.org
Contents
When you innovate, you've got to be prepared for everyone telling you you're nuts.
– Larry Ellison
C Programming 22
C++ Programming 222
Linux 381
Git Commands 545
Algorithm 549
The Most Significant Failures When Al Turned Rogue, Causing Disastrous Results 574
Is DevOps a good career? 585
Android 589
Docker Commands 614
Java Programming 618
Structured Query Language 737
Basic MongoDB Commands 761
HTML 1082
CSS 1202
30 Bash Scripts for Beginners 1274
Whether you want to uncover the secrets of the universe, or you just
− Stephen Hawking
(One of the most brilliant theoretical physicists in human history)
Programming language
{
Single line comment
// Hello World Program
1
C Keywords
, < > . _
( ) ; $ :
% [ ] # ?
' & { } "
^ ! * / |
- \ ~ +
Non-numeric
Numeric
Character String
Floating-point
Integer
2
Data types:
\' Single quote return 0; // This returns control to the operating system
\" Double quote } // This marks the end of main()
\? Question mark
\0 End of string
# Output: Albert!!
3
Format specifiers in C
%p Read a pointer
%s Read a string
%n Prints nothing
%% Prints % character
C Operators
Unary Ternary
Binary
4
• Arithmetic operators
Operations Operator
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
• Relational operators
Operator Meaning
< Lesser than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to
• Logical operators
Operator Meaning
&& Logical AND
|| Logical OR
! Logical NOT
• Bitwise operators
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Exclusive –OR (XOR)
~ 1's complement
<< Left shifting of bits
>> Right shifting of bits
5
Shorthand operators
Mathematical Functions
Function Description
6
#include<stdio.h>
#include <math.h>
int main() {
// ceil() function rounds a number upwards to its nearest integer
printf("%f\n", ceil(2.6));
// Output: 3.000000
/*
* Multi-line
* Comment.
*/
Multi-line comments
/*******************************************
* Multi-line *
* Comment. *
*******************************************/
#include<stdio.h>
int main(void) {
printf("\"Albert Einstein was a German-born theoretical \"\nphysicist\n");
return 0;
}
Output:
"Albert Einstein was a German-born theoretical "
physicist
7
C Header files
Preprocessor Directives
#include<stdio.h>
stdio.h is a standard header file required to
#define NUMBER_OF_APPLES 24
use input/output functions such as printf()
int main(void) {
printf("There are %d apples in a basket.\n", NUMBER_OF_APPLES);
return 0;
}
8
#include<stdio.h>
#include<stdio.h>
// define a macro ab with the value 25
int main() {
#define ab 25 int x = 16;
int y = (x++, ++x);
int main() { printf("%d", y);
return 0;
/******************************************************* }
// Output: 18
When the #ifdef condition is encountered:
If ab macro is defined: #ifdef condition is executed
If ab macro is not defined: #else condition is executed
******************************************************/
#ifdef ab
printf("Your lucky number is: %d\n", ab);
#else Output:
printf("Error: printing lucky number!"); Your lucky number is: 25
#endif
return 0;
#include<stdio.h>
}
int main() {
#ifdef ab
Development of C Program: printf("Your lucky number is: %d\n", ab);
#else
Source Code
printf("Error: printing lucky number!");
#endif
Preprocessor
return 0;
}
Compiler Output:
Library Error: printing lucky number!
Linker
Executable program
9
ASCII Table
10
Data Conversion Functions
Function Use
Function Use
#include <ctype.h>
#include <stdio.h>
Output:
int main() {
char x = '8';
8 is a hexadecimal character.
if (isxdigit(x) != 0) {
printf("%c is a hexadecimal character.", x);
} /* end if */
else {
printf("%c is not a hexadecimal character.", x);
} /* end else */
return 0;
}
11
String Manipulation Functions
Function Use
#include <stdio.h>
int main() {
double z;
int x = 5;
int y = 8;
z = (double)(x + y)/2 - (x + y)/(double)(x*x + y*y);
printf("%f", z); If marks is greater than or equal to 35 then
#include <stdio.h>
return 0; printf("Passed\n") otherwise printf( "Failed\n" )
int main() {
} is executed
int marks = 15;
marks >= 35 ? printf( "Passed\n" ) : printf( "Failed\n" );
// Output: 6.353933 return 0;
}
// Output: Failed
12
Searching and Sorting Functions
Function Use
Function Use
fopen() opens new or existing file
fprintf() write data into the file
fscanf() reads data from the file
fputc() writes a character into the file
fgetc() reads a character from file
fclose() closes the file
fseek() sets the file pointer to a given position
fputw() writes an integer to file
fgetw() reads an integer from file
ftell() returns current position
rewind() sets the file pointer to the beginning of the file
#include <stdio.h>
int main() {
int x = 3; /* loop 10 times */
while(x <= 10) {
x = 3 * x;
printf("%d", x);
} /* end while */ Output:
}
927
Function Use
13
realloc() increases or decreases the size of the specified block of memory,
moving it if necessary
Flowchart
Complexity:
14
start #include <stdio.h> #include <stdio.h>
int main() { int main() {
int a = 10, b = 2; int a = 10, b = 2;
a /= b + 1; a = a/(b + 1);
Read radius printf("%d", a); printf("%d", a);
return 0; return 0;
} }
// Output: 3
Area = 4 × 3.142 × radius × radius
#include<stdio.h>
int main() {
float radius; /* radius to be input by user */
float area; /* variable in which area will be stored */
printf("Enter the radius: "); /* prompt */
scanf("%f", &radius); /* read an radius */
area = 4 * 3.14 * radius * radius; /* assign product to area */
printf("Area of a sphere = %f", area); /* print area */
return 0;
}
Output:
Enter the radius: 2.6 # entered radius
15
Logical statements:
BASIC SYNTAX:
if (condition) {
Execute all statements inside the body if the condition is true If syntax
}
if (condition) {
Execute all statements inside the body if the condition is true
} else { Else syntax
if (condition1) {
Execute all statements inside the body if condition1 is true
} else if (condition2) {
Execute all statements inside the body if the condition1 is false and condition2 is true
} else {
Execute all statements inside the body if the condition1 is false and condition2 is false
}
Else if syntax
16
Break syntax
do {
while (condition) { // statements
// statements if (condition to break) {
if (condition to break) { break;
break; }
} // statements
// statements }
} while (condition);
#include <stdio.h>
#include <stdio.h>
int main() {
int main() {
int y =10;
int y =10;
if(y > 6) {
int x = y > 6 ? 25 : 50;
int x = 25;
printf( "%d", x);
printf( "%d", x);
return 0;
} else {
}
int x = 50;
printf( "%d", x);
}
return 0; Output:
} 25
17
Continue syntax
while (condition) { do {
// statements // statements
if (condition to break) { if (condition to break) {
continue; continue;
} }
// statements // statements
} }
while (condition);
#include<stdio.h> Output:
Switch syntax
/* function main begins program execution */
1
int main() {
switch (expression) { 2
int i = 1; /* initialization */
case 1: 3
while(i<=10) { /* repetition condition */ 4
// statements
break; printf("%d\n", i); /* display counter */ 5
case 2: i++; /* increment */ 6
// statements 7
} /* end while */
break; 8
return 0; /* indicate program ended successfully */
default: 9
} /* end function main */ 10
// statements
}
18
For Loop syntax
while (condition) {
do {
// statements
// statements
}
}
while (condition);
#include <stdio.h>
#include <string.h>
int main() {
int num = 1;
printf("We have seen %d cat%s.", num, num == 1 ? "" : "s");
return 0;
}
#include <stdio.h>
#include <string.h>
int main() {
int num = 2;
printf("We have seen %d cat%s.", num, num == 1 ? "" : "s");
return 0;
}
19
Nested-if statement:
Goto statement:
#include <stdio.h>
#include <stdio.h> int main() {
int main() { int a = 10;
int sum=0; if (a == 10) {
for(int i = 1; i<=9; i++) { if (a < 15)
sum = sum+i; printf("\n a is smaller than 15");
if(i==5) { if (a < 12)
goto addition; // Go to the statement labeled addition printf("\n a is smaller than 12");
} else
} printf("\n a is greater than 15");
addition: }
printf("%d", sum); return 0;
return 0; }
}
// Output:
// Output: 15 # 1+2+3+4+5 = 15 a is smaller than 15
a is smaller than 12
20
#include <stdio.h>
int main() {
#include <stdio.h>
for(int x = 1, y = 2 ; x <= 6 ; x++, y = y + 1) int main() {
printf(" %3d", x*y); printf("Albert \" 1905 Papers \\\".");
return 0; return 0;
} }
#include<stdio.h>
int main() {
printf("\n **************");
This expression executes once when the loop starts.
It declares "i" and initializes it to 1.
21
C Programming
Developer Dennis Ritchie & Bell Labs (creators); ANSI X3J11 (ANSI C); ISO/IEC
JTC1/SC22/WG14 (ISO C)
OS Cross-platform
Creator of C language
Major implementations
Dialects
Influenced by
Influenced
22
C, D, Go, Java, JavaScript, Julia, Limbo, LPC, Perl, PHP, Pike, Processing, Python, Ring, Rust
A general-purpose, procedural, High Level Programming most widely used computer Language developed by a
man named Dennis Ritchie in 1970s at Bell Telephone laboratories (now named AT & T Bell laboratories),
Murray Hill, New Jersey to develop system application that directly interacts with the hardware devices such as
drivers, kernels, etc. [UNIX operating system] using the two early programming languages − Basic Combined
Programming Language (BCPL) and BASIC (Beginner's All-purpose Symbolic Instruction Code) language.
• RDBMS MySQL, Language Compilers and Interpreters, Print Spoolers, Loaders, Linkers,
Assemblers, Text Editors, Automation tools, Network Drivers.
Most of the state-of-the-art software has been developed using C. C has also greatly influenced many other popular
languages [considered as the base for other programming languages − mother language], especially C++, which
was originally designed as an enhancement to C. Most of the programming languages follow C syntax [For example:
C++, Java, C#, etc.]
#include <stdio.h>
#include <stdlib.h>
Output:
int main() {
printf("Hello World"); Aborted
abort(); // abnormal termination of the program
return 0;
}
Advantages:
23
▪ Easy to understand and supports a rich set of data types
▪ Easy to use, write, modify and debug and quick to learn
▪ can be compiled on a variety of computer platforms
▪ C supports bitwise operators – Bitwise AND, OR, XOR, bitwise complement, left and right shift
operators.
▪ C provides a variety of conditional control statements • if-statement
• if-else statement
The ALGOL-based language formalized in 1988
• nested-if statement
by the American National Standard Institute
• switch statement
(ANSI) and can handle low-level activities
C is called a structured programming language because it divides the problem into smaller modules called
functions or procedures each of which handles a particular responsibility. Hence it is simple and easy to understand
and well suited for small size implementation. However this is not restricted. A large size implementation is possible
but complex design and full object oriented design cannot be implemented (because complex design concepts like
Polymorphism and inheritance are not available in C). C is widely used in IOT applications.
#include <stdio.h>
#include <stdlib.h> Output:
int main() {
printf("Hello World"); Hello World
exit(EXIT_SUCCESS); // normal termination of the program
return 0;
} #include <stdio.h>
int main() {
Output:
char x[] = "Albert Einstein!";
puts(x);
Albert Einstein!
return 0;
}
24
Characters Set: #include <stdio.h>
int main() {
Upper case char x[] = {'A', 'l', 'b', 'e', 'r', 't', '\0'};
char y[] = "Albert";
Alphabets printf("%lu\n", sizeof(x)); // Output: 7
Lower case printf("%lu\n", sizeof(y)); // Output: 7
return 0;
Digits [0−9] }
Special characters:
~ Tilde
! Exclamation mark
# Number sign
$ Dollar sign
% Percent sign
^ Caret
& Ampersand
* Asterisk
( Lest parenthesis
) Right parenthesis
_ Underscore
+ Plus sign
| Vertical bar
\ Backslash
` Apostrophe
- Minus sign
= Equal to sign
{ Left brace
25
} Right brace
[ Left bracket
] Right bracket
: Colon
; Semicolon
? Question mark
, Comma
. Period
/ Slash
• Blank space
Limitation: C can't be used for
• New line
White spaces internet programming like Java,
• Carriage return
.Net, PHP, etc.
• Horizontal tab
#include <stdio.h>
int main() {
int a, b;
Output:
a = 2, 4, 6;
b = (2, 4, 6);
printf("a = %d, b = %d\n", a, b); a = 2, b = 6
return 0;
}
#include <stdio.h>
int main() {
Features of C:
int x=30; // A local variable
• Simple static int y=30; // A static variable
x=x+1;
• Machine Independent or Portable
y=y+1;
• Mid-level programming language printf("%d, %d", x, y); // Output: 31, 31
return 0;
• structured programming language
}
• Rich Library
26
• Memory Management
#include <stdio.h>
• Fast Speed
int main() {
• Pointers
• Recursion int x = 20.397;
return 0;
TOKEN
#include<stdio.h>
• Variables
The above program give raise to
• Statements and Expressions
an infinite recursive calls to
• Comments main(). The console screen will
be flooded with Hi's
27
int main() main function. Execution of C program begins from main()
#include<stdio.h>
return 0;
#include <stdio.h>
#include<stdio.h> int main() {
int main() { int a = 18;
#include<stdio.h>
int x, y; int b = 5;
int x=17, y=18; // Global variables declaration
x = 6; printf("%ld", sizeof(a+b));
and initialization
int main() { y = x++ / 2; // Output: 4
printf("%d", y); return 0;
printf("x = %d and y = %d", x, y);
// Output: 3 }
// Output: x = 17 and y = 18
return 0;
The above program displays
return 0; }
the actual size of the
} given expression (a+b)
Process of C Program Execution: Every 'C' program follows a basic structure. A C program:
28
return 0; //Terminating function
is written using Text Editor such as [Notepad (in case of Windows Operating System), vim or vi
(in case of Linux Operating System)] and saved with [.c] Extension − for example, hello.c.
File Saved with [.c] extension is called Source Program or Source Code. C Source code with
[.c] Extension is sent to preprocessor first.
The preprocessor generates an expanded source code. Expanded source code is given as input to compiler where the
expanded source program is compiled (i.e., the program is entirely read and translated to instructions the computer can
understand i.e., machine understandable and readable language i.e., to machine code sequence of 0s and 1s). If the C
compiler finds any error during compilation, it provides information about the error to the programmer.
The programmer has to review code and re-edit the program. After re-editing program, Compiler again check for
any error. If program is error-free then it is sent to assembler [where the code is assembled and converted into object
code. Now a simple.obj file is generated].
#include<stdio.h>
0100000000000000000
int main() 0111111111111111111
{ 0101010101010101010
0000000111111111111
printf("Hello,world!");
0000000000000001010
return 0;
1111000000000000000
}
C compilation process converts the source code taken as input into the object code or machine code.
The object code is sent to linker (where the object code is linked with appropriate libraries). Then it is converted into a
single executable code. A simple.exe file is generated. The executable code is sent to loader (where the executable code
Hello,world!
29
#include <stdio.h> // include the input/output related functions in C program
int main() { /* function main begins program execution */
int sum = 0; // Stores the sum of the integers
int i = 0; // The number of integers to be summed
printf("\n Enter a number: "); /* prompt */
scanf(" %d", &i); // Read the number of integers to be summed
// Sum integers from 1 to i
for(int x = 1; x<=i; sum += x++);
printf("\n The sum of the first %d integers is: %d\n", i, sum); /* print sum */
return 0; /* indicate that program ended successfully */
} /* end function main */
Output:
Enter a number: 10 # entered number
Output:
Enter a number: 10 # entered number
This statement begins with # symbol and is also called preprocessor directive. This statement directs the C
preprocessor to include header file [stdio.h] and also symbolic constants [standard input output functions] into a
C program. "stdio" means standard input output and stdio.h means standard input output header file.
printf() and scanf() are not part of the C language because there is no input or output defined in
C language itself − stdio.h comprises standard input output functions like scanf, printf etc.
30
stdio.h is a header file library that add functionality to C programs and allows standard input /output operations
and it is included into the C program by writing the statement #include<stdio.h>
• scanf is an input function and printf is an output function
• Letter "f " denote formatted
#include<stdio.h>
then the C compiler can't compile and a compilation error is displayed on the screen because C compiler
fails to recognize the functions such as printf() and scanf().
We can also write #include "stdio.h" [user define library header file] instead of #include
<stdio.h> [predefine library header file] but #include "stdio.h" is added by programmer and
#include<stdio.h> is already exist in compiler. So the statement #include<stdio.h> is
generally preferred and the statement #include "stdio.h" is generally ignored.
As the name itself indicates this is the main function of every C Program. Parentheses () indicate a function
and the word main indicate the name of the function.
Execution of C program begins from main(). No C program is executed without main(). It is case sensitive:
only lower case letters (or small letters) must be used and should not be enclosed by a semicolon. There must
be one and only one main() function in every C program.
• main()
• int main()
• void main()
• main(void)
• void main(void)
• int main(void)
31
As we know C is a Platform dependent language. So the Operating system needs to know when the program
execution ends. So when there is value return from the main function, the Operating System gets to know that
the program execution is over.
• If the main function returns 0 to the operating system, then the program has
completed execution successfully.
• If the main function returns 1 to the operating system, then the program
has not completed execution successfully.
int main() {
Body of the main function within which the sequence of instructions to the computer to
perform specific operations in the form of statements [input-output statements, arithmetic
statements, control statements and other statements] are written and executed
implies: the beginning of the main function and the right curly brace
implies: the end of the main function. These braces can also be used to indicate the beginning and end of user-defined
functions and compound statements.
return 0; → implies the exit status of execution of the program i.e., at this point, main function returns back the
control of the computer to the operating system since the execution is terminated at this point and once a return
statement i.e., return 0; executed, no further instructions within the main function are executed.
For example:
32
#include<stdio.h>
int main() {
printf("Hello,world!");
return 0;
printf("Hello,world!");
}
Hello,world!
; → implies semicolon or statement terminator [a delimiter of the declaration] → In C language: each statement
must end with a semicolon. A program is a well-defined set of instructions and each well-defined instruction (in the
form of a statement) is ended by a semicolon
A good programmer who writes codes understood by a human is better than a programmer who generates codes
understood only by the machine. So, it is highly recommended to insert comments. Comment is explanatory note
on some instruction. The statement to be commented on must be enclosed within /* and */. Comment statement is
not compiled and executed.
printf()→ the standard way of displaying output on the screen and output function of the C language which
makes provision to print the output:
Hello,world!
on the screen. Parentheses () indicate a function and the word printf indicate the name of the function. The text:
Hello, world! should be enclosed by the double quotation marks (" ") and should be written within the printf
function and this printf function should be ended with the semicolon i.e.,
33
printf("Hello,world!");
scanf() gets()
printf() puts()
getchar() getch()
putchar() getche()
# Output: Output:
Enter a character: A # entered character Enter a string: Albert # entered string
A # output You entered:
the character: "A" and the string: "lbert"
"
34
#include <stdio.h> /* For puts function */
#include <stdbool.h> /* For bool function */
int main(void) {
bool a = true; /* equivalent to bool a = 1; */
bool b = false; /* equivalent to bool b = 0; */
if ((a != 0) || (a != false)) { /* Functionally equivalent to if (a) */
puts("Albert");
}
if ((b == 0) || (b == false)) { /* Functionally equivalent to if (!b) */
puts("Einstein");
}
Output:
}
Albert
Einstein
Single Character A, a, X, 5 1
Single Digit 1,3,8,0 1
Single Symbol ?, *, #,$ 1
Whole Number 22,-102,3610 2
Fractional number 0.1,1.25,0.56729 4
Instruction Add, Multiply (1 - 3)
Big Whole / Fractional number 922112580, 12550.126 (4 - 10)
35
12 1100 C
13 1101 D
14 1110 E
15 1111 F
16 10000 10
17 10001 11
18 10010 12
19 10011 13
20 10100 14
21 10101 15
22 10110 16
23 10111 17
24 11000 18
25 11001 19
26 11010 1A
27 11011 1B
28 11100 1C
29 11101 1D
30 11110 1E
31 11111 1F
32 100000 20
64 1000000 40
128 10000000 80
256 100000000 100
• Program 1.1
C program to print the word "Hello Bill Gates" on screen
36
Hello Bill Gates
• The first line tells the compiler to include standard input output header file
#include <stdio.h> to perform reading and printing of data.
• The second line is the main function of a C program. The body of C program contains
only two statements i.e.,
When this statement is taken for execution, main() calls the printf()
and printf()is included in <stdio.h> . Then printf() prints:
Hello Bill Gates on the computer screen.
return 0;
Macro substitution: Process of replacing an identifier of a C program by a symbolic constant.This can be achieved
by the directive #define.
#include<stdio.h>
#define PI 3.14 /* define a macro */
int main() /* function main begins program execution */
{
float r, area; /* declare variables */
r = 2.5;
area = PI * r * r; /* assign product to area */
printf("The area of the circle = %f", area); /* display result */
return 0; /* indicate that program ended successfully */
} /* end function main */
Output:
The area of the circle = 19.625000
#include<stdio.h>
37
#define PRINT printf("x is greater than y");
int main() {
int x, y;
x=16; Output:
y=2;
x is greater than y
CONDITION
PRINT
return 0;
}
#include <stdio.h>
#include<stdio.h>
int main() {
int main(){
int y;
double x = 56.3;
int x = 12;
int y = (int)x + 50; // data type casting
y = (x >= 16) ? 16 : x;
printf("%f\n", x); // Output: 56.300000
printf("y = %d", y);
printf("%d\n", y); // Output: 56 + 50 = 106
return 0;
return 0;
}
}
// Output: y = 12
• Program 1.2
C program to print
*****
*****
#include <stdio.h>
***** int main() {
int y;
***** int x = 12;
if (x >= 16) y = 16; else y = x;
on screen
printf("y = %d", y);
#include<stdio.h> return 0;
int main() }
{ // Output: y = 12
38
#include <stdio.h>
printf("\n * ");
int main(void) {
printf("\n ***** ");
enum x{physics= 65, math=95, biology=86};
printf("\n ***** ");
printf("Physics marks: %d\n", physics);
printf("\n ***** ");
printf("Biology marks: %d\n", biology);
printf("\n ***** ");
return 0;
return 0;
} Output:
}
Physics marks: 65
Biology marks: 86
The output on the screen:
*
*****
*****
*****
*****
If new line sequence (\n) is not included in the above program then the output on the screen is:
*********************
#include <stdio.h>
Write a program to print the following outputs:
int main() {
int i = 10;
char x = 'A';
(a)
int z = i + x;
printf("%d\n", z);
* return 0;
**** }
*******
// Output: 75
****
// 10 + 65
*
// ASCII value of A = 65
(b)
39
#include <stdio.h>
int main() {
****************
typedef int physics;
**************** // Output:
Physics marks: 86
(c)
Braces come in pairs!
Comments come in pairs!
All statements end with a semicolon!
Spaces are optional!
Must have a main function!
C is done mostly in lowercase. It's a case-sensitive language
#include<stdio.h>
#include<conio.h>
int main() {
const int x = 8; // x is 8
x = 15 ; // generates an error
printf("x = %d", x);
return 0;
Because we are trying to
Answers: }
change the value of the
constant variable
(a)
#include<stdio.h>
#include <stdbool.h>
int main()
#include <stdio.h>
{
int main() {
printf("\n * ");
int x = 30, y = 24;
printf("\n **** ");
bool res = ((x != y) && printf("Albert"));
printf("\n ******* ");
return 0;
printf("\n **** ");
}
printf("\n * ");
return 0;
// Output: Albert
}
40
• If x is true, then: !x will be false.
(b)
• If x is false, then: !x will be true.
#include<stdio.h>
int main()
{
printf("\n **************** ");
printf("\n * * ");
printf("\n * Hello World! * ");
printf("\n * * ");
printf("\n **************** ");
return 0;
} #include <stdbool.h>
#include <stdio.h>
int main() {
The variables represent a particular memory location where the data can be stored.
Their value can be altered and they can be reused many times.
int x;
float y;
char z;
Here: x, y, z represent variables. The int, float, char represent the data types.
int x = 15;
41
• Special characters should not be used as variables
• Representing the variable names in lowercase is a virtue programming practice.
• There is no limit on the number of characters in a variable name.
Method 1: int x = 1;
Method 2: int x;
x = 1;
• Program 1.3
#include<stdio.h>
/* function main begins program execution */
int main() {
int x, area; // create variables 'x' and 'area' of data type int
x = 2; // assign the value 2 to x
area = 6 * x * x; /* assign product to area */
printf("The total surface area of a cube = %d", area); // print area
return 0; /* indicate that program ended successfully */
} /* end function main */
42
The total surface area of a cube = 24
int
Keyword used to indicate an integer number. Any integer is a sequence of digits
without a decimal point.
Valid Invalid
-248 3,266
14028 -34.0
+1988 +5,456.3
0 999999999999
56780
An attribute that tells what kind of data that value can own
int means the data type is integer and the storage size of int data type is usually 2 bytes (consumes a total of 16 bits
in memory). And it can take 232 distinct states from -2147483648 to 2147483647. If your computer is an 8-bit
device, then the range of int is given by:
Note:
• A string, for example, is a data type that is used to categorize text and an
integer is a data type used to categorize whole numbers or non fractional values
[0,-5, 10].
• If we use int data type to store decimal values, decimal values will be shortened
and we will get only whole number. In this case, float data type can be used to
store decimal values in a variable.
The statement
int x, area;
43
imply that we are declaring two integer variables:
• x
• area
and these variables represent some memory location where the data is stored. Each variable is associated with a
value. The processof giving values to variables is called assignment of values. The assignment operator or storage
operator (" = ") is used to assign a value to a variable.
The statements
x = 2;
area = 6 * x * x;
imply that we are assigning the values to the declared variables where:
6 * 2 * 2 = 24
• area → represents the memory location where the value '24' is stored.
int x, area;
The statement
on the screen.
44
In the statement:
Format string or format specifier "%d" indicates that the integer value to be displayed
after the statement:
If you want to supply the value for x through the key board, then the statement
int x, area;
x = 2;
int x;
int area;
printf("Enter any number:");
scanf("%d", &x);
#include<stdio.h>
int main() {
45
The output on the screen:
We use print() to put up an output message and scanf() to read the user input into variable "x".
The statement
on the screen.
• To read the values for the variables in a C program from the keyboard, C provides a
function called scanf(). It is equivalent to the READ statement in FORTRAN or PASCAL.
• scanf()→ accepts numeric, character and string type of data. It is included in stdio.h.
• & symbol imply the address and "&x" imply the address of memory location where the
value of input variable "x" should be stored. " %d" specification is used to input
integer data through the keyboard.
The statement:
scanf("%d", &x);
make provision to enter a number for "x" through the keyboard and tells the input function
scanf to read the number entered through the keyboard for "x" (which is a integer) and store
it in the address of "x" in the computer memory (i.e., store the number in "&x").
46
Note:
As you enter an integer for "x" through the keyboard, this integer will be stored in the computer memory. If
you want to know the storage size of the integer in computer memory (i.e., space occupied by the
entered integer in the computer memory), you need to appeal to the following program:
#include<stdio.h>
/* function main begins program execution */
int main() {
int x; /* number to be input by user */
printf("Enter any number: "); /* prompt */
scanf("%d", &x); /* read an number */
printf("Size of x = %ld", sizeof(x)); /* print the size of a variable x */
return 0; /* indicate that program ended successfully */
} /* end function main */
i.e., integer entered for "x" i.e., 2 has occupied a space of 4 bytes in the computer memory.
Field width:
scanf("%3d", &x);
• If input number = 3485 [4 digits]: only 3 digits [348] are stored in the memory location
of an input number. If the input number has more digits than the specified field width
then all extra digits are not stored.
a = 5, b = 6
Unary minus: c = a + (-b) = 5 + (-6) = -1
47
▪ Format Specifiers in C
Void data type: A void data type doesn't contain or return any value. It is mostly used for
• Octal constant contains digits from 0-7, and these types of constants are always preceded...by .0.
• Hexadecimal constant contains a digit from 0-9 as well as characters from A-F..
Output:
#include<stdio.h>
/* function main begins program execution */ Enter any number: 5496 # entered number
int main() { You entered: 549
int x; /* number to be input by user */
printf("Enter any number: "); /* prompt */
scanf("%3d", &x);
48
#include<stdio.h> #include<stdio.h>
int main() { int main() {
for(int i=1;i<=4;i++) { for(int j=1;j<=4;j++) {
printf("* "); for(int i=1;i<=4;i++) {
} printf("* ");
Nested loop
printf("\n"); }
printf("\n");
for(int i=1;i<=4;i++) { }
printf("* "); return 0;
} }
printf("\n");
for(int i=1;i<=4;i++) {
printf("* ");
}
printf("\n");
for(int i=1;i<=4;i++) {
Output:
printf("* ");
} * * * *
printf("\n");
* * * *
* * * *
return 0;
* * * *
}
#include<stdio.h>
int main() {
float r, area;
printf("Enter the radius: "); A simple example of C language that
scanf("%f", &r); gets input from the user and prints
area = 3.14 * r * r; the area of the circle
printf("The area of the circle = %f", area);
return 0;
}
Output:
Enter the radius: 2.5 # entered radius
49
float means the data type is float. This keyword is used to indicate a floating-point
number. They are termed floating-point because of the shifting of the decimal point
either to the left or the right of some digits during manipulation.
Mantissa-exponent notation:
Valid Invalid
-263.269 0,0
2.3698 E+03 -3.3.3
0.0268963 E+06 -9999999999.9999999 (out of range)
3689.6 E-04 -+44.44
The statement:
float r, area;
#include<stdio.h>
int main() {
float length, breadth, area;
length = 2.5;
C program to print the area of
breadth = 3.2;
the rectangle (given length =
area = length*breadth;
2.5 and breadth = 3.2)
printf("The area of the rectangle = %f", area);
return 0;
}
50
/* Print one line with three printf statements */ /* Print multiple lines with a single printf */
Mathison
// Output: Alan Mathison Turing.
Turing
#include <stdio.h>
int main() {
Output:
int x; /* first number to be input by user */
Enter a number: 5 # entered number
int y; /* second number to be input by user */
Enter a number: 4 # entered number
int sum; /* variable in which sum will be stored */
Sum of 5 and 4 is: 9
printf( "Enter a number: " ); /* prompt */
51
#include <stdio.h>
Lazy initialization
int main() {
i++; /* increment i */
Initial value of
control variable
Increment of
Loop-continuation control variable
condition
52
#include <stdio.h>
int main() {
int a = 2, b = 4;
for(int i = a; i <= 2 * a * b; i += b / a) {
Output:
printf("Hi\n");
Hi
} Hi
#include <stdio.h>
return 0; Hi
int main() {
Hi
}
int a = 2, b = 4;
Hi
for(int i = 2; i <= 16; i += 2) {
Hi
printf("Hi\n"); Hi
} Hi
return 0;
#include <stdio.h> Since 500 is greater than -1 we would expect the output:
return 0;
}
which is greater than 500: implying that x > y is false.
// Output: x < y
53
#include <stdio.h>
int main() {
_Bool b = 1;
_Bool c = 0;
puts("Einstein");
}
#include <stdio.h>
int main() {
#define Square(b) ((b)*(b))
printf("%d\n", Square(3+2));
int main() {
return 0;
printf("%d\n", Square(3+2));
}
return 0;
Separation of Concerns
A programatic approach to divide a software application into individual manageable units with minimal overlapping
between the functions of the individual units
54
#include <stdio.h>
return 0;
}
#include <stdio.h>
int main() {
#include <stdio.h>
int x = 1905;
int MIN(int a, int b) {
char y = 'X';
return 0;
int main() {
}
int x = 2;
// Output: 1905, X, Papers
printf("%d\n", MIN(x+1, 20)); // Output: 3
return 0;
#include <stdio.h>
int main() {
float x;
x = 0.2;
Prints "0.200000 > 0.2" since "x" is float
if (x > 0.2) printf("%f > 0.2", x);
return 0;
55
C program to find the sum of two numbers
#include<stdio.h>
int main()
int mult(int a, int b) {
{ mult.h
return(a*b);
int a, b, sum;
}
a=1;
b=2;
sum = a + b;
#include<stdio.h>
printf("The sum of a and b = %d", sum);
#include<mult.h>
return 0;
int main() {
}
int x;
x = mult(6,3);
The output on the screen: printf("6×3 = %d\n", x);
return 0;
The sum of a and b = 3
}
// Output: 6×3 = 18
If you want to assign the floating -point numbers i.e., fractional numbers for a
and b (i.e., 1.5 for a and 2.6 for b) through the keyboard, then the statement:
int a, b, sum;
56
printf("The sum of a and b = %f", sum);
#include <stdio.h>
i.e.,
int main() {int x=22; printf("%d\n" , x); return 0;}
// Output: 22
#include<stdio.h>
int main()
{
float a, b, sum;
a=1.5;
b=2.6;
sum = a + b;
} Grapes
The statement:
Orange
#include <stdio.h>
make provision to print the output:
int main() {
57
is omitted from the C program, the program will be successfully executed but there
will be no display of the output on the screen.
If you want to supply the values for a and b through the key board, then the statements:
#include<stdio.h>
a=1.5; int main() {
b=2.6; /* string initialized at declaration character wise */
char x[4] = {'A', 'l', 'a', 'n'};
printf("%s\n", x); // Output: Alan
58
#include <stdio.h>
The sum of a and b = 6.5
int main() {
int x =2, y=4;
will be outputted on the screen.
x+=y+1; // x = x + y + 1
printf("%d\n", x);
// Output: 7
return 0;
As Said Earlier: }
ampersand ("&") imply the address and [&a and &b] imply the addresses of the
declared floating-point variables a and b stored in the computer memory i.e.,
when we enter a number for a and b through the keyboard, these numbers are
read by scanf() function and they are stored in the computer memory (i.e., the
number entered for a is stored in the address of a (i.e., stored in &a) and
the number entered for b is stored in the address of b (i.e., stored in &b)).
One format string "%f" corresponds to "&a" i.e., %f tells the scanf()
function to read the number entered through the keyboard for "a" and store
it in the address of "a" in the computer memory.
and the other format string "%f" corresponds to "&b" i.e., %f tells the
scanf() function to read the number entered through the keyboard for "b" and
store it in the address of "b" in the computer memory.
• Note:
59
The statement:
read the two numbers 2.9 and 3.6 entered through the keyboard and store them in the computer memory [i.e., the
number 2.9 is stored in the address of "a" (i.e., stored in &a) and the number 3.6 is stored in the address of
"b" (i.e., stored in &b)].
The statements:
60
scanf("%f", &b);
sum = a+ b;
printf("The sum of a and b = %f", sum);
return 0;
}
#include<stdio.h>
int main() {
char * x = ((13 % 2)==0) ? "TRUE" : "FALSE";
#include<stdio.h>
int main() {
for(int x =0 ; x < 5; x++) { // outer loop
Then the output on the screen is:
for(int y=0; y < 5; y+=2) { // inner loop
printf("*");
}
The sum of 2.9 and 3.6 = 6.5
}
return 0;
} // Output: ***************
61
In the statement
• The format string %f after the statement (The sum of) indicates that the value to be
• The format string %f after the statement (The sum of %f and) indicates that the value
• The format string %f after the statement (The sum of %f and %f =) indicates that the
• Program 1.4
C program to convert the temperature in Celsius to Fahrenheit
C++ Program:
#include<stdio.h>
int main()
#include<iostream>
{
using namespace std;
float C, F;
int main() {
C=38.5;
F = 9*C/5 +32; int x = 20;
62
#include<stdio.h>
int main() {
int x = 3; This program demonstrates how the do...while
do {
printf("Albert"); structure runs its program at least once. Initially
x--; x=3, loop enters, printf() prints, x = 3−1=2, now
} while (x < 2);
condition is checked, 2<2 = False, so loop exits
return 0;
}
// Output: Albert
If you want to supply the number 16 digits after decimal point for C through the key board,
then the above program should take the form:
#include<stdio.h>
#include<stdlib.h>
#include<stdio.h>
int main() {
int main()
for(int x=1; x<=6; x++) {
{
if(x % 4 == 0)
double C, F;
printf("Enter any number:"); exit(0);
scanf("%lf", &C); else
F = 9*C/5 +32; printf ("%d ", x);
printf("Temperature in Fahrenheit= %lf", F); }
// %lf is used because the data type for F is double return 0;
return 0;
}
}
// Output: 1 2 3
▪ Note:
234.0000000000000000
− 0.0000000099531510
63
The data type double and long double are used to store real numbers with precision up to 14
and …80 bits respectively.
int x = y = 10;
float x = y = z = 6.76;
64
Answer:
#include<stdio.h>
#include<stdio.h> int main() {
int main() int x = 64;
{ if(x > 68 && x < 54)
int a, b, c, sum; printf("x > 68 and < 54");
else
printf("Enter any three numbers:");
scanf("%d %d %d", &a, &b, &c); printf("%d", x);
sum = a + b + c; return 0;
}
printf("The sum of a, b and c = %d", sum);
return 0;
} // Output: 64
#include<stdio.h>
#include<stdlib.h>
Answer:
int main() {
// declaring & initializing variables
#include<stdio.h> int a = 20, b = 4, c;
int main()
// doing math operations
{
c = a / b;
int a = 45; //displaying result
printf("%x", a);
printf("%d / %d = %d \n", a, b, c);
return 0;
// asking user to press key
}
printf("Enter any character to exit: \n");
// holding program till key press
getchar();
// exit program with status 0, no error
Output on the screen:
exit(0);
2d } // end of main
20 / 4 = 5
Enter any character to exit:
K # entered character
...Program finished with exit code 0
65
• Write a program to print the area of a triangle when three sides are given.
The math.h file is added to the program to use sqrt() function
#include<stdio.h>
#include<math.h>
#define PI 3.14159
Answer:
int main() {
float x, y, theta, area;
#include<stdio.h> printf("Enter any 2 sides of triangle: \n");
#include<math.h> scanf("%f %f", &x, &y);
int main() printf("Enter any one side angle in degrees: \n");
{ scanf("%f", &theta);
b= 4; return 0;
c=5; }
s = (a + b + c) / 2;
Finding area of triangle
area = sqrt((s * (s-a) * (s-b) * (s-c)));
when 2 sides and one
printf("The area of the triangle = %d", area);
angle are given
return 0;
}
▪ Note: since sqrt() is not part of C language or of standard input output file (i.e.,
stdio.h file), it is part of math file i.e., (math.h file which defines various
mathematical functions) the statement:
#include<math.h>
should be included in the C program otherwise the compilation error will be flagged on
the screen stating that sqrt() is not declared or defined.
66
is written instead of
Then the compilation error will be displayed on the screen because C does not support
• Program 1.5
C++ Program:
// Output:
67
The product of a and b = 2
a=1000000000
#include <stdio.h>
b=3000000000
int main() {
printf("1 TO 5 MULTIPLICATION TABLE: \n\n");
, then the statement: for(int x=1; x<= 5; x++) {
for(int y=1; y<= 5; y++)
1 TO 5 MULTIPLICATION TABLE:
and %ld should be used instead of %d 1 2 3 4 5
2 4 6 8 10
i.e., the program should be rewritten as:
3 6 9 12 15
4 8 12 16 20
#include<stdio.h>
5 10 15 20 25
int main()
{
// Output: 16
68
The product of a and b = 3000000000000000000
If you want to supply the values for a and b through the key board, then the statements
a=1;
#include <stdio.h>
b=2;
#define begin {
#define end }
#define program int main()
should be replaced by the statements #define writeln printf
writeln("Einstein");
end
i.e.,
// Output: Albert Einstein
#include<stdio.h>
int main()
int a, b, product;
product = a* b;
69
If you enter two numbers 1 and 3
C++ Program:
#include <iostream>
using namespace std;
70
printf("The product of a and b = %d", product);
i.e., instead of variable separator (i.e., comma) semicolon is used − Then the compilation
#include<iostream>
▪ Note:
using namespace std;
#include <stdio.h> void func1(const string &i) {
int main() cout << i << endl;
{ }
void func2(string i) {
printf("Hello, World!");
cout << i << endl;
printf("Hello, World!\b"); }
printf("Hello, World!\b"); int main() {
printf("Hello, World!\b");
func1("Albert");
func2("Albert");
return 0; Output:
return 0;
}
} Albert
Albert
#include <stdio.h>
int main()
{
printf("Hello, World!");
printf("Hello, World!\r");
71
printf("Hello, World!\r");
#include<stdio.h>
printf("Hello, World!\r");
int main() {
return 0;
int x;
}
printf("Enter any number: \n");
scanf("%d", &x);
(x == 2 ? printf("Albert") : printf("Einstein"));
The output on the screen is: return 0;
}
C++ Program:
#include <stdio.h>
#include<iostream>
int main()
using namespace std;
{
int main() {
printf("Hello, World!\t");
printf("Hello, World!\t"); int x=2, y=3, z=0;
72
#include <stdio.h>
#include <iostream>
printf("Hello, World!\v");
using namespace std;
printf("Hello, World!\v");
namespace Y {
The output on the screen is: double a = 4.5496;
double b = 3.1988;
}
Hello, World!
Hello, World!
Hello, World! int main () {
Hello, World! using X::a;
using Y::b;
cout << a << endl; // 25
cout << b << endl; // 3.1988
• Program 1.5 cout << X::b << endl; // 50
C program to find the square of a number cout << Y::a << endl; // 4.5496
return 0;
#include<stdio.h>
}
int main()
{
int a, b;
a=2; #include<stdio.h>
b = a * a;
int main() {
printf("The square of a = %d", b);
} printf("%f",16.0+17);
// Output: 33.000000
73
The square of a = 4 C++ Program:
#include<iostream>
If the statement: using namespace std;
int main() {
b = a * a;
int x, y, z, g;
cout<<"Enter any 3 numbers: \n";
cin>>x>>y>>z;
is replaced by (x > y ? (x > z ? g = x : g = z) : (y > z ? g = y : g = z));
cout<< g << " is the greatest of 3 numbers.";
b = pow((a), 2);
return 0;
}
#include<stdio.h>
#include<math.h>
int main()
Output:
{
return 0;
Then there will be no display of compilation error on the screen or there will be no change in
the output on the screen i.e.,
The square of a = 4
which means:
74
b = pow((a), 2); is the same as b = a*a;
If you want to supply the integer value for "a" through the key board, then the statement:
a=2;
return 0;
75
Enter any number:
If you enter a number 4
the square of a = 16 will be outputted on the screen.
• Note:
• If scanf(%d, &a); is written instead of scanf("%d", &a);
• If printf(The square of a = %d, b); is written instead of
int main()
#include <stdio.h>
{
int main() {
};
int a = 3, b, c;
b = a = 10;
c = a < 10;
is written instead of printf("\na: %d b: %d c: %d", a, b, c);
// Output: a: 10 b: 10 c: 0
int main()
return 0;
{
}
}
int main()
{
76
}; → NO ERROR
#include <stdio.h>
• Write a program to print the cube of a number
int main() {
int a, b; return 0;
a=2; }
b = pow((a), 3);
printf("The cube of a = %d", b); // Output: Albert
return 0; // ASCII value of 'B' is 66
}
• Write a program to print the energy of the substance using energy = mc2
Answer:
#include<stdio.h>
#include<stdio.h> int main() {
#include<math.h>
int a = 25 ;
int main()
printf("%d %d %d", a != 25, a = 20, a < 35);
{
// Output: 1 20 1
int m;
return 0;
long int c, energy; }
m=2;
c = 300000000;
77
The syntax of if statement is:
C++ Program:
#include<stdio.h>
int main()
#include<iostream>
{
using namespace std;
Simple Compound
• Compound statement → A collection of two or more statements placed between the braces.
• Program 1.6
C program to find the greatest of two numbers using if - else statement
78
• The syntax of if – else statement (Conditional Statement):
?
print this statement; return(0);
}
}
Output
#include<stdio.h>
#include <stdio.h>
int main()
int main() {
{
int x = 10, y = 15;
int a, b;
if(x % 2 == y % 3)
a = 2;
printf("Albert");
b = 3;
else
if(a>b)
printf("Einstein");
{ return 0;
printf("a is greater than b"); }
}
// Output: Albert
else
return 0;
79
b is greater than a
a>b
within the parentheses is not true, the statement a is greater than b is not executed; instead the
execution skips and pass to print the statement b is greater than a.
In simpler words, (a>b) is the condition (i.e., logical expression that results
in true or false) and if the condition (a>b) is true, then the statement:
#include<stdio.h>
printf("a is greater than b");
#include<stdlib.h>
int main() {
int x = 0;
x+1;
is executed to print the output:
if(x<=5) {
a is greater than b printf("Albert Einstein");
exit(0);
else the statement:
main();
}
}
printf("b is greater than a");
b is greater than a
If you want to supply the integer values for a and b through the key board, then the statements
80
a=2;
b=3; should be replaced by the statements:
#include<stdio.h>
int main() {
i.e., the program should be rewritten as:
int x, i = 75;
#include<stdio.h> x = (i > 18 ? (i <= 85 ? 500 : 1000) : 190);
int main() printf ("%d", x) ;
{
return 0;
int a, b; }
printf("Enter any number:");
scanf("%d", &a); // Output: 500
printf("Enter any number:");
scanf("%d", &b);
if(a>b)
}
#include<stdio.h>
else
int main() {
{ int x = 0, y = 1;
printf("b is greater than a"); if(x == 0)
}
(y > 1 ? printf("Albert") : printf("Einstein"));
else
return 0;
printf("Albert Einstein");
}
return 0;
}
81
will be outputted on the screen.
When a series of decision is required, nested if-else is used. Nesting means using one if-else
construct within another one. #include<stdio.h>
int main() {
#include<stdio.h> char x[10];
int main()
printf("Enter your name: \n");
{
fgets(x, 4, stdin);
int a =1;
if(a<10) printf("I'm delighted to have you, %s.\n", x);
{ return(0);
if(a==1) }
{
printf("The value is:%d\n", a);
}
else
{
printf("The value is greater than 1");
}
}
else
{
printf("The value is greater than 10");
}
return 0;
} Enter your name:
• Program 1.7
C program to find the greatest of three numbers using if - else if - else statement
82
if (this condition is true) #include<stdio.h>
{ int main() {
} printf("%d\n", x--);
{ main();
} }
else // Output:
4
{
3
print this statement;
2
}
1
#include<stdio.h>
#include<stdio.h> int main() {
int main() int x=12, y;
{
x >= 15 ? (y = 10) : (y = 15);
int a, b, c;
printf("%d %d", x, y);
printf("Enter any number:");
return 0;
scanf("%d", &a);
}
printf("Enter any number:");
scanf("%d", &b);
printf("Enter any number:"); // Output: 12 15
scanf("%d", &c);
if(a>b&&a>c)
{
printf("%d is greater than %d and %d", a, b, c);
}
else if (b>a&&b>c)
{
printf("%d is greater than %d and %d", b, a, c);
}
else
{
printf("%d is greater than %d and %d", c, b, a);
83
}
#include<stdio.h>
return 0;
int main() {
}
int x = 0;
while(x++ < 5)
printf("%d ", x);
The output on the screen: return 0;
}
(b>a&&b>c) // Output: B
}
i.e., the condition
(a>b&&a>c) imply:
84
is executed to print the output:
is not executed; instead the execution skips and passes to the condition (b>a&&b>c)
// Output: Albert
85
printf("c is greater than b and a");
If the statements:
if(a>b&&a>c)
{
printf("%d is greater than %d and %d", a, b, c);
}
else if (b>a&&b>c)
{ #include<stdio.h>
printf("%d is greater than %d and %d", b, a, c); #include<stdlib.h>
}
else
int main() {
{
int x, y = 3;
printf("%d is greater than %d and %d", c, b, a);
switch(x = y + 1) {
}
case 4:
printf ("Albert");
break;
default:
are replaced by the statements: printf ("Elsa");
}
if(a>b&&a>c)
return 0;
printf("%d is greater than %d and %d", a, b, c); }
else if (b>a&&b>c)
else
#include<stdio.h>
86
int main()
#include<stdio.h>
{
int main() {
int a, b, c;
int x = 5;
printf("Enter any number:");
while(x == 5) {
scanf("%d", &a);
printf("Enter any number:"); x = x - 5;
scanf("%d", &b); printf("%d", x);
printf("Enter any number:"); }
scanf("%d", &c); return 0;
if(a>b&&a>c) }
printf("%d is greater than %d and %d", a, b, c);
else if (b>a&&b>c)
// Output: 0
printf("%d is greater than %d and %d", b, a, c);
else
printf("%d is greater than %d and %d", c, b, a);
return 0;
}
#include<stdio.h>
#include <stdio.h> int main() {
int main() do {
{ The loop's body is
printf("Albert");
int a, b; executed first and
} while(14 < 11);
a=2; only after that is
return 0;
b=2; the condition
} tested
if(a>b || a==b)
printf("a is greater than or equal to b");
// Output: Albert
else
printf("b is greater than a");
return 0;
87
} #include<stdio.h>
int main() {
for(int i=0;i<3;i=i+1,printf("%d ", i))
Answer: ;
return(0);
Note:
#include<stdio.h>
#include <string.h>
int main() {
• Program 1.8 char x[] = "Einstein";
C program to find the average of 10 numbers char y[15] = "Albert ";
strcat(y, x);
printf("%s", y);
#include<stdio.h> return 0;
int main() }
{
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, X;
// Output: Albert Einstein
printf("Enter any 10 numbers:");
scanf("%d%d%d%d%d%d%d%d%d%d", &N1, &N2, &N3, &N4, &N5, &N6, &N7, &N8, &N9, &N10);
X = (N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9 + N10) /10;
printf("The average of 10 numbers = %d", X);
return 0;
}
88
Note: The average of 10 numbers is 5.5, the output on the screen is 5 because the data
type int is used instead of float.
(ax + 1) (by + 2) (a * x + 1) * (b * y + 2)
x
log 10 ( + c) log 10 (x/y + c)
y
ax2+bx+c a*x*x+b*x+c
lnx log(x)
x
e +b exp (x) + b
sinθ + cosθ sin (theta) + cos (theta)
α=β+γ alpha = beta + gamma
√x sqrt(x)
3
√x cbrt(x)
89
2a2 + 3b 2a *a + 3b + 2
x a = exp ( x / sqrt ( 1 + sin (theta)))
a=e√1+sinθ
(a) #include<stdio.h>
int main() {
int i;
for(i=5; i<6; i=i+1) {
#include<stdio.h>
printf("%d\n", i);
#include<math.h>
int main()
}
{ return(0);
int a, b, x; }
x=2;
b=2; // Output: 5
a = exp(x) + b;
printf("The value of a = %d", a);
return 0;
}
Answer: #include<stdio.h>
int main() {
int i;
The value of a = 9
for(;i>=-5;i--)
printf("%d ",i);
return(0);
}
(b)
// Output: 0 -1 -2 -3 -4 -5
90
#include<stdio.h> #include<stdio.h>
#include<math.h> #define x 5
int main() int main() {
{ for(int i=1;i<=10;i++)
int alpha, beta, gamma; printf("%d %% %d = %d\n", i, x, i%x);
alpha =2;
return(0);
beta=2;
}
gamma= 2 * alpha + beta;
printf("The value of gamma = %d", gamma); Output:
return 0;
1 % 5 = 1
}
2 % 5 = 2
3 % 5 = 3
4 % 5 = 4
Answer:
5 % 5 = 0
6 % 5 = 1
7 % 5 = 2
The value of gamma = 6
8 % 5 = 3
9 % 5 = 4
10 % 5 = 0
(c)
#include <stdio.h>
#include<math.h>
int main()
#include<stdio.h>
{
double theta, result;
int main() {
// Output: Albert
Answer:
91
#include<stdio.h>
int main() {
The sine 90 degrees is = 0.893997
char *names[] = {
"Albert",
"Alan",
"John",
𝐱
What is C equivalent expression of [ 𝐲 ] n −1 ? "James",
"Mary"
};
Answer: for(int i=0;i<5;i++) {
puts(names[i]);
pow((x/y), n-1) }
# Output:
return(0);
}
Albert
Alan
• Program 1.9 John
#include<stdio.h>
#include<stdio.h> int main() {
#include<math.h> printf("%%14s = %14s\n","Albert");
int main()
return(0);
{
}
int a, b;
printf("Enter any number:");
// Output: %14s = Albert
scanf("%d", & a);
b = sqrt(a);
printf("The square root of a number = %d", b); #include<stdio.h>
return 0; #include<stdlib.h>
} int main() {
int i;
int *pi;
pi=&i;
The output on the screen:
for(i=1;i<=5;i++)
printf("%d ",*pi);
Enter any number: return 0;
}
If you enter the number 4
// Output: 1 2 3 4 5
92
The square root of a number = 2
√2 = 1.41421356237
Suppose if you enter the number " 2", the square root of a number = 1 is outputted on the screen
because int is used instead of float.
#include<stdio.h>
#include<ctype.h>
int main() {
char x;
printf("Do you want to be like Albert Einstein?\n");
scanf("%c", &x);
x = toupper(x);
Output:
if(x=='Y')
puts("Albert"); Do you want to be like Albert Einstein?
else y # entered character
puts("Elsa"); Albert
return(0);
}
C++ Program:
#include<stdio.h>
int main() {
char *names[] = { #include<iostream>
putchar('\n'); }
}
return(0);
}
93
#include<stdio.h>
int main() {
char x = 'B'; C++ Program:
switch(x) {
case 'A': #include<iostream>
case 'E': using namespace std;
case 'I':
case 'O': int main() {
case 'U': const char x = '2';
printf("Vowel"); const char y = x + 1;
break; const char z = '\n';
default: cout << y << z;
printf("Not a vowel"); return 0;
} }
return 0;
} // Output: 3
#include<stdio.h>
#include<math.h>
int main()
{
printf("The square root of a number = %f", sqrt(4));
return 0;
}
|| imply or
> imply greater than
< imply less than
== imply equal to
! imply not
!= imply not equal to
&& imply and
94
& imply address
C++ Program:
#include<iostream>
▪ Program 2.0
using namespace std;
C program to find the simple interest int main() {
string x = "Albert Einstein";
for(auto i : x)
#include<stdio.h> cout << i;
int main() return 0;
{
}
int P,T, R, SI;
P = 1000;
// Output: Albert Einstein
T = 2;
R = 3;
SI = P*T*R/100;
#include<iostream>
printf("The simple interest = %d", SI);
using namespace std;
return 0;
int main() {
}
string x = "Albert ";
string y = "Einstein";
x += y;
The output on the screen:
cout<< x <<endl;
return 0;
The simple interest = 60
}
// Output: Albert Einstein
▪ Note:
If you write SI = PTR/100; instead of SI=P*T*R/100;
Then compilation error is displayed on the screen because C language does not accept the
general expressions.
If you want to supply the values for P, T and R through the key board, then the statements:
P = 1000;
T = 2;
95
R = 3; C++ Program:
#include<iostream>
should be replaced by the statements: using namespace std;
int main() {
printf("Enter principal amount:"); string x = "Alan";
scanf("%d", &P); string y = "Albert";
printf("Enter time:"); const char *z = ", ";
scanf("%d", &T); string w = x + z + y + " ...";
printf("Enter rate of interest:"); cout<< w <<endl;
scanf("%d", &R); return 0;
}
scanf("%d", &T); }
printf("Enter rate of interest:");
scanf("%d", &R); // Output: Albert nor Elsa
SI = P*T*R/100;
printf("The simple interest = %d", SI);
#include<iostream>
return 0;
using namespace std;
}
int main() {
string x = "Albert and Elsa";
x.replace(x.begin() + 10, x.end(), " Alan");
cout<< x <<endl;
The output on the screen: return 0;
}
Enter principal amount:
// Output: Albert and Alan
96
If you enter the principal amount 1000
Enter time:
If you enter the time 2 Weekly Active Users:
Enter rate of interest:
If you enter the rate of interest 3 The number of unique users who have
interacted with a platform or web application
The simple interest = 60 over the course of a week
goto statement: Like other languages, C supports an unconditional control statement [goto] to
transfer the control from one point to another in a C program. The goto is a branching
statement and requires a label. The syntax of goto statement is as follows:
goto label;
The label can be written anywhere in the C program either before or after the goto statement. For
example:
………………… …………………
………………… …………………
………………… …………………
END: goto START;
…………………
97
if statement
if-else statement
else-if statement
• Program 2.1
C program to find whether the person is senior citizen or not
#include<iostream>
#include<stdio.h>
int main() #include<vector>
{ using namespace std;
int age; int main() {
age=20; vector<int> primes = {2, 3, 5, 7, 11, 13};
if(age> = 60) for(auto x : primes) {
{
cout << x << endl;
printf("senior citizen");
} Output:
}
return 0; 2
if(age<60)
} 3
{
printf("not a senior citizen"); 5
} 7
return 0; 11
}
13
Zero-based numbering:
The output on the screen:
98
If you want to supply the value for age through the key board, then the statement:
age=20;
#include<iostream>
using namespace std;
#include<stdio.h> #include<iostream>
int main() using namespace std;
{ int main() {
int age; string x = "Alan Mathison Turing";
printf("Enter age:"); x.replace(x.begin() + 6, x.begin() + 9, 3, '*');
scanf("%d", &age);
cout<<x<<endl;
if(age>60)
return 0;
{
}
printf("senior citizen");
// Output: Alan M***ison Turing
}
if(age<60)
{ #include<iostream>
99
If you enter the value 60
#include<iostream>
senior citizen will be outputted on the screen.
using namespace std;
int main() {
Suppose if you enter the value 27
constexpr int x = 22 * 4;
not a senior citizen will be outputted on the screen.
cout << x << endl;
// Output: 88
return 0;
• Program 2.2 }
#include<iostream>
using namespace std;
#include<stdio.h>
int main() {
int main()
int x = ((cout << "Albert"), 0);
{
int M1, M2,M3; return 0;
M1 = 38; }
M2= 45;
M3 = 67; // Output: Albert
if(M1>= 35 && M2>= 35 && M3>= 35)
{
#include<iostream>
printf("candidate is passed");
using namespace std;
}
int main() {
else
struct x {int a, b;};
{
class y {
printf("candidate is failed");
public:
}
int a, b;
return 0;
};
}
enum class names {Albert, Alan, John};
cout << is_class<x>::value << "\n";
// Prints 1 (True)
cout << is_class<y>::value << "\n";
// Prints 1 (True)
The output on the screen:
cout << is_class<names>::value << "\n";
// Prints 0 (False)
candidate is passed return 0;
}
100
>= imply greater than or equal to and double ampersand imply and
(M1>= 35 && M2>= 35 && M3>= 35) denote the condition and this condition imply M1 is greater
than or equal to 35 and M2 is greater than or equal to 35 and M3 is greater than or equal to 35.
And if this condition is TRUE, then the statement:
{ #include<iostream>
printf("candidate is passed"); using namespace std;
} int main() {
is executed to print the output:
for(int x = 1; x <= 2; ++x)
candidate is passed
for(int y = 1; y <= 2; ++y)
else the statement
cout << '[' << x << ',' << y << "]\n";
{
printf("candidate is failed");
return 0;
} }
// Output:
[1,2]
[2,2]
If you want to supply the integer values for marks M1, M2 and M3 through the key board, then..the
statements:
#include<iostream>
101
i.e.,
#include<stdio.h>
int main() {
#include<stdio.h> int x=14; x++ & printf("%d\n", x);
int main()
// Output: 15
{
return 0;
int M1, M2, M3;
}
printf("Enter any three numbers:");
scanf("%d%d%d", &M1, &M2, &M3);
if(M1>= 35 && M2>= 35 && M3>= 35) #include<stdio.h>
{ int main() {
printf("candidate is passed"); int x=14; x++ && printf("%d\n", x);
} // Output: 15
else return 0;
{
}
printf("candidate is failed");
} #include<iostream>
return 0; struct C {
} int x;
char y;
float z;
};
#include<stdio.h>
#include<ctype.h>
int main() A method of programming that wraps data in functions
{
102
int a=2;
#include<iostream>
if(isalpha(a))
using namespace std;
{
int main() {
printf("The character a is an alphabet");
int x{50};
}
else cout << x << endl;
{ // Output: 50
printf("The character a is not an alphabet"); return 0;
} }
return 0;
} #include<iostream>
using namespace std;
int main() {
{
printf("The character a is not an alphabet");
}
#include<iostream>
return 0;
}
using namespace std;
int main() {
cout << 10/3 << " " << 3/10 << endl;
// Output: 3 0
The output on the screen:
cout << 10.0/3.0 << " " << 3.0/10.0 << endl;
// Output: 3.33333 0.3
The character a is an alphabet return 0;
}
103
If the statement char a = b; is written instead of char a = 'b'; Then the compilation error will be
flagged on the display screen.
#include<iostream>
104
{
#include<iostream>
printf("profit=%d", SP-CP);
} using namespace std;
int main() {
int x;
cout<<"Enter any number: \n";
is executed to print the output:
cin.operator>>(x);
cout.operator<<(x);
profit = SP-CP (in this case profit = 26-25 =1)
return 0;
}
#include<stdio.h>
int main() // Output:
{
Enter any number:
float I, C;
25 # entered number
I=3.5;
25
C = 2.54*I;
105
}
Array function: A user-defined task function that is
specifically intended to process an array
#include<iostream>
using namespace std;
int main() {
string x = "Albert";
cout << "\"" << x << "\" contains " << x.length() << " letters." << endl;
return 0;
} // Output: "Albert" contains 6 letters.
If you want to supply the floating-point variable for " I" through the key board, then the above
program should take the form: #include<iostream>
using namespace std;
106
Increment operator: This operator is used to increment the value of an integer number by 1.
This is represented by '++' [double plus] symbol. This symbol can be placed after the integer
variable. For example, if int a = 4; then, a++ indicate a = a+1. Thus, the value of "a" is 5.
Decrement operator: This operator is used to reduce the value of an integer number by 1. This
is represented by '--' [double minus] symbol. This symbol can be placed after the integer
variable. For example, if int a = 4; then, a-- indicate a = a-1. Thus, the value of "a" is 3.
• Program 2.5
#include<stdio.h>
int main()
Machine dependent:
{
int a, b, c, d, e, f; A programming language feature that alters
a = 10;
based on the CPU of the computer
b=12;
c=a+1;
d=b+1;
Variable:
e=a-1;
f=b-1;
A piece of data whose value is
printf("The incremented value of a =%d", c);
printf("The incremented value of b =%d", d); subject to change while the
printf("The decremented value of a =%d", e);
programme is running
printf("The decremented value of b =%d", f);
return 0;
}
Array
The output on the screen: A grouping in order of similar data type elements that
share a single name for identification
107
The incremented value of a = 11 The incremented value of b = 13 The decremented value
of a = 9 The decremented value of b = 11
Parameter passing:
If the statements:
How data is passed into and
Truncation:
OR sizeof
Versatile:
The incremented value of a = 11
The incremented value of b = 13 Simple code modification to handle a
The decremented value of a = 9
The decremented value of b = 11
different data type
108
#include<iostream> Please type one line of content here:
#include<string> Albert Einstein # entered text
using namespace std; You entered: "Albert"
int main() {
string x;
cout <<"Please type one line of content here: \n";
cin >> x;
cout <<"You entered: \"" << x << "\"" << endl;
return 0;
}
If you want to supply the values for a and b through the key board, then the above program
should take the form:
Branching:
109
d=b+1;
e=a-1;
f=b-1;
printf("The incremented value of a =%d\n", c);
printf("The incremented value of b =%d\n", d);
printf("The decremented value of a =%d\n", e);
printf("The decremented value of b =%d\n", f);
return 0;
} #include<iostream>
#include<vector>
using namespace std;
Bitwise complement:
During bitwise complement operation each zero gets changed to 1 and each one gets changed to 0.
110
Consider the binary number 10000100. It is equivalent to 132 in decimal.
• Decimal number: 13
• Dividing the Decimal number [13] repeatedly by 2 until we get the quotient as 0:
13 / 2 = 6 (Remainder = 1)
6 / 2 = 3 (Remainder = 0)
3 / 2 = 1 (Remainder = 1)
1 / 2 = 0 (Remainder = 1)
1 1 0 1
#include<stdio.h>
int main()
{
int a, b;
a=128;
b=32;
a=a>>1;
printf("After right-shifting by 1, a =%d\n", a);
b=b<<2;
printf("After left-shifting by 2, b =%d\n", b);
return 0;
111
}
Little's Law
The percentage marks are entered and the grades are allotted as follows:
percentage>= 60 First Class
#include<iostream>
percentage>=50 and per <= 60 Second Class using namespace std;
percentage>= 40 and per <= 50 Pass Class
percentage< 40 Fail int main() {
int x = 2;
cout << x << endl;
Write a C program for the above:
// Output: 2
cout.operator<<(x).operator<<(endl);
#include<stdio.h>
// Output: 2
int main()
return 0;
{
}
int P;
printf("Enter the percentage:");
scanf("%d", &P);
#include<iostream>
if(P >= 60)
using namespace std;
{
printf("first class");
int main() {
} string x = "Albert";
if(P>=50&&P <60) cout << x.operator[](3) << endl;
{ // Output: e
printf("second class"); cout << x[3] << endl;
} // Output: e
else if(P>=40&&P<=50 )
return 0;
{ The letter at index 3
}
printf("pass class");
112
}
#include<iostream>
else
using namespace std;
{
int main() {
printf("fail");
int x = 0;
}
return 0; while (x < 5) {
} cout << "*";
x++;
}
cout << endl;
return 0;
The output on the screen:
}
• Program 2.7
C program to calculate the discounted price and the total price after discount
Given:
▪ If purchase value is greater than 1000, 10% discount #include<iostream>
▪ If purchase value is greater than 5000, 20% discount using namespace std;
▪ If purchase value is greater than 10000, 30% discount int main() {
int x = 5;
while (x < 6) {
• Discounted price
if (x % 5 == 0)
cout << "*";
#include<stdio.h>
x++;
int main()
}
{
cout << endl;
double PV, dis;
printf("Enter purchased value:"); return 0;
scanf("%lf", &PV); }
if(PV>1000)
{ // Output: *
printf("dis=%lf", PV* 0.1);
113
}
Java Program:
else if(PV>5000)
{ public class MyClass {
printf("dis =%lf", PV* 0.2);
public static void main(String[] args) {
}
Boolean x = Boolean.TRUE;
else
if (x) {
{
printf("dis=%lf", PV* 0.3); System.out.println("Albert");
} }
return 0; }
} }
// Output: Albert
import java.util.Scanner;
public class MyClass {
114
}
public class MyClass {
else
{ public static void main(String[] args) {
printf("total=%lf", PV- PV* 0.3); String x = String.format("%.2f", 1.5496);
}
return 0; System.out.println(x);
} // Output: 1.55
#include<stdio.h>
int main()
{ public class MyClass {
double PV, dis, total;
printf("Enter purchased value:"); public static void main(String[] args) {
scanf("%lf", &PV); String x = String.format("%.3f", 1.5496);
if(PV>1000)
{ System.out.println(x);
else if(PV>5000) }
{
printf("dis =%lf", PV* 0.2);
printf("total=%lf", PV - PV* 0.2);
}
else
{
115
printf("dis=%lf", PV* 0.3);
printf("total=%lf", PV - PV* 0.3);
} import java.text.DecimalFormat;
return 0; public class MyClass {
}
public static void main(String[] args) {
String x = new
DecimalFormat("0.#").format(5.6400);
The output on the screen:
System.out.println(x);
// Output: 5.6
}
Enter purchased value:
}
If you enter the purchased value 850
dis = 85.000000
total = 765.000000
will be outputted on the screen.
import java.text.DecimalFormat;
public class MyClass {
public static void main(String[] args) {
String x = new DecimalFormat("0.##").format(1.6534000);
System.out.println(x);
// Output: 1.65
}
}
116
Jakob's law
Users expect that your website function similarly to all the other websites
What is a Loop?
A Loop executes the sequence of statements many times until the stated condition becomes false.
Types of Loops: Depending upon the position of a control statement in a program, a loop is
classified into two types:
• Entry controlled loop → a condition is checked before executing the body of a loop. It is
also called as a pre-checking loop.
• Exit controlled loop → a condition is checked after executing the body of a loop. It is
also called as a post-checking loop.
• Program 2.8
C program to print the first ten natural numbers using for loop statement
#include<stdio.h>
int main() import java.text.DecimalFormat;
{
int i;
public class MyClass {
for(i=1; i<=10; i++)
public static void main(String[] args) {
printf("value of i =%d", i);
String x = new DecimalFormat("0").format(987653421);
return 0;
}
System.out.println(x);
// Output: 987653421
}
}
The output on the screen is:
117
for(i=1; i<=10; i++) denote the for loop statement and the syntax of the
for loop statement is:
Here:
The number of iterations required to execute the body of for loop is computed using the formula:
i = 1
Is the condition (i<=10) is true?
Yes because i=1
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 1
Now, the value of i is:
i = 1+1 = 2
Is the condition (i<=10) is true?
Yes because i=2
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 2
118
Now, the value of i is:
i = 2+1 = 3
Is the condition (i<=10) is true?
Yes because i=3
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 3
Now, the value of i is:
i = 3+1 = 4
Is the condition (i<=10) is true?
Yes because i=4
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 4
Now, the value of i is:
i = 4+1 = 5
Is the condition (i<=10) is true?
Yes because i=5
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 5
Now, the value of i is:
i = 5+1 = 6
Is the condition (i<=10) is true?
Yes because i=6
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 6
Now, the value of i is:
i = 6+1 = 7
Is the condition (i<=10) is true?
Yes because i=7
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 7
Now, the value of i is:
i = 7+1 = 8
Is the condition (i<=10) is true?
Yes because i=8
The statement printf("value of i =%d", i); is executed to print the output:
value of i = 8
Now, the value of i is:
i = 8+1 = 9
Is the condition (i<=10) is true?
Yes because i=9
The statement printf("value of i =%d", i); is executed to print the output:
119
value of i = 9
Now, the value of i is:
i = 9+1 = 10
Is the condition (i<=10) is true?
value of i = 10
If the statement:
120
value of i = 6 public class MyClass {
value of i = 7 public static void main(String[] args) {
value of i = 8 int x = 2147483647;
value of i = 9
System.out.println(x); // prints 2147483647
value of i = 10
x = x + 1;
System.out.println(x); // prints -2147483648
}
If the for loop statement:
}
121
Note: the condition i<=10 tells to print till value of i =10 but the condition
i<10 tells to print till value of i=9.
If the statement:
continues ....
#include <stdio.h>
#include <stdio.h>
void myfunc(int* x, double* y) {
int main() {
*x = 64;
for(int i = 1; i != 5; i++) {
*y = 296.0;
printf( "%f\n", (float) i / 10 );
}
}
return 0;
int main() {
} Output:
int w = 0;
0.100000 double z = 0.0;
0.200000 myfunc(&w , &z);
0.300000 printf("w: %d, z: %f\n", w , z);
Note: 0.400000 return 0;
}
If the statement:
Output:
printf("value of i =%d", i);
w: 64, z: 296.000000
122
printf("%d\n", i);
#include <stdio.h>
int main() {
Then the output on the screen is:
for(int i = 2; i <= 10; i += 2) {
printf( "%d\n", i );
1
}
2 return 0;
3 }
4
5 # Output:
6
7 2
8 4
9 6
10 8
10
#include<stdio.h>
int main()
{
int i; /* define i */
Answer: return 0;
}
123
Linux is not portable
Linux is not portable
Linux is not portable
Linux is not portable
#include <stdio.h>
int main() {
#include<stdio.h>
int a = 25;
int main()
int b = 92;
{
int i = 1; printf("%d, %d\n", 1 ? a : b, 0 ? a : b);
while (i<=10) return 0;
{ }
printf("%d\n", i++);
} // Output: 25, 92
return 0;
}
#include <stdio.h>
int main() {
int a = 102, b = 102;
The output on the screen is: printf("%d\n", (a *= 3, b));
return 0;
}
1
2 // Output: 102
3
124
4
#include <stdio.h>
5
int main() {
6
int x[] = { 11, 12, 13, 14, 15 };
7
printf("x[3] = %d\n", x[3]);
8
9 printf("4[x] = %d\n", 4[x]);
10 return 0;
}
Output:
x[3] = 14
(i<=10) is the condition and 4[x] = 15
The statement:
printf("%d\n", i++);
Then the compilation error will be displayed on the console screen because initialization is
notdefined i.e., from where to start is not declared. #include <stdio.h>
#include <string.h>
If the statement: int main() {
int i = 1; char x[] = "albert";
char y[8];
is replaced by
strcpy(y, x); // copying x to y
125
Then the output on the screen is:
0
1
#include <stdio.h>
2
int main() {
3
char *x = NULL;
4
5 printf("%s", x);
6 return 0;
7 }
8
9 // Output: (null)
10
7
8
9
10
#include <stdio.h>
The syntax of do while loop statement is: int main() {
int x = 63;
int y = -25;
do
/* 'y == -25' is not evaluated,
{ since 'x != 63' is false. */
Execute this statement; if (x != 63 && y == -25) {
} printf("Albert\n");
}
while(this is the condition);
else {
printf("Einstein\n");
}
return 0;
#include<stdio.h> }
int main()
// Output: Einstein
126
{
int i =1; #include <stdio.h>
do
#define max(a, b) ((a) > (b) ? (a) : (b))
{
printf("i= %d\n", i++); int main() {
} while (i<=10);
int x = max(22, 53); /* Output: 53 */
return 0;
} printf("%d\n", x);
printf("%d\n", y);
}
i=1
i=2
i=3
#include <stdio.h>
int main() {
i=4
int x = 5;
i=5
if ((x > 1) && (x > 2)) {
i=6
puts("x is larger than 1 and 2");
i=7
}
i=8
else {
i=9
puts("x is not larger than 1 and 2");
i=10
}
return 0;
The statement:
}
is executed and then condition (i<=10) is checked. If condition (i<=10) is true then
The statement:
127
printf("i= %d\n", i++);
is executed again. This process repeats until the given condition (i<=10) becomes false.
If loop is not used then the C program to print first 10 numbers should be written as follows:
#include<stdio.h>
#include <stdio.h>
printf("\n i = 1");
const char *x = "Alan Turing"; /* initialize char pointer */
char i = 'a'; /* initialize 'i' */
printf("\n i = 2");
/* if 'i' is present in 'x' */
printf("\n i = 3");
if (strchr(x, i) != NULL) {
printf("\n i = 4"); printf( "\'%c\' is present in \"%s\".\n", i, x);
printf("\n i = 5"); } /* end if */
printf("\n i = 6");
else { /* if 'i' is not present in 'x' */
printf( "\'%c\' is not present in \"%s\".\n", i, x);
printf("\n i = 7");
} /* end else */
printf("\n i = 8");
return 0;
printf("\n i = 9"); } Output:
printf("\n i = 10");
return 0; 'a' is present in "Alan Turing".
}
It takes pretty long time to write the code and the execution time is pretty long i.e., because to
reduce the time taken to write the code and to reduce the execution time − loop statement is used.
Never test for an error condition you don't know how to handle
128
Answer:
#include<stdio.h>
int main()
{
int i;
for (i =1; i<=5; i ++)
printf("Never test for an error condition you don't know how to handle \n");
return 0;
#include <stdio.h>
}
#include <string.h>
int main() {
const char *x = "Alan Turing"; /* initialize char pointer */
▪ Note: char i = 'z'; /* initialize 'i' */
/* if 'i' is present in 'x' */
int i; }
Output:
for (i=1; i=5; i++)
Linux is not portable Linux is not portable Linux is not portable Linux is not portable
Linux is not portable Linux is not portable Linux is not portable Linux is not portable
Linux is not portable Linux is not portable Linux is not portable Linux is not portable
Linux is not portable …. continues
129
• Program 2.9
C program to print the characters from A to Z using for loop, do while loop and while
loop statement.
#include <stdio.h>
#include <string.h>
#include<stdio.h>
int main () {
int main()
const char x[] = "Users/Manju/1.txt";
{
const char i = '/';
char a;
char *y;
for(a='A'; a<='Z'; a++) Searches for the last occurrence of
return 0; ('Users/Manju/1.txt')
y = strrchr(x, i);
130
O
#include <stdio.h>
P
int main() {
Q
printf("%10s%10d%10c%10f\n\n", "Albert", 19, 'E', 1.05 );
R
return 0;
S
T }
W
Output:
X
Y Albert 19 E 1.050000
Z
• char → Keyword used to denote the character type data and takes 8-bits for
storage.
• A character constant can be termed as any single character enclosed within a
pair of apostrophes ['a','c','2','$','?', etc.].
• A string constant is termed as a sequence of printable ASCII characters placed
between double quotes. Examples: "computer","keyboard","Hello","Ram", etc.
The statement
char a; imply that we are creating the character 'a'.
Since char a is used. Therefore: the format specifier %c should be used instead of %d or %f
otherwise error will be flagged on the screen. #include <stdio.h>
int main() {
131
for(a='A'; a<='Z'; a++)
• Analyze the problem and check whether it requires a pre-test or a post-test loop.
#include<stdio.h>
#include <stdio.h>
int main()
int main() {
{
char a = 'A'; printf( "%+09d\n", 5496 );
while (a<='Z') // Output: +00005496
{ printf( "%09d\n", 5496 );
printf("%c\n", a++); // Output: 000005496
} return 0;
return 0;
}
}
#include<stdio.h>
int main()
{
char a = 'A';
do
132
{ for(i=3;i<=100;i=i+3)
printf(" %c\n", a++);
} while (a<='Z');
return 0; The loop starts at 3 because of the i=3 part of the for loop and
} increments up to 100 by using the i=i+3 formula. The for loop reads like
this: "Start with i equal to 3 − and while the value of i is less than
100 − repeat the following: adding 3 to variable i each time we loop. It
stops at 100 because of the i<=100 part of the loop."
• Program 3.0
C program to print the given number is even or odd.
#include <stdio.h>
#include<stdio.h>
int main() {
int main()
int a, b;
{
printf( "Enter a number: " );
int a;
scanf( "%2d%d", &a, &b );
printf("Enter any number:");
scanf ("%d", &a); printf( "%d and %d\n", a, b);
if(a%2 == 0) return 0;
{ }
printf("The number is even");
} // Output:
else
{ Enter a number: 54968 # entered number
// Output: i: 15
Enter any number:
133
• Mathematical symbol % denote modulus and (a%2 == 0) is the condition and this
condition imply: a divided by 2 yields reminder = 0.
#include <stdio.h>
For example: if you enter the number 4
int main() {
Then a = 4
for(int i=1; i<10; i++)
Then 4 divided by 2 yields the remainder = 0 putchar('.');
Then the statement: return 0;
}
#include <stdio.h>
134
• Program 3.1
C program to print the remainder of two numbers
#include <stdio.h>
#include<stdio.h>
int main() {
int main()
{ int i = 52;
int a, b, c;
printf("%d", i>25); // Output: 1 (True)
printf("Enter any number:");
scanf("%d", &a); return 0;
printf("Enter any number:");
}
scanf("%d", &b);
c = a%b;
printf("The remainder of a and b = %d", c);
return 0;
}
#include <stdio.h>
int main() {
int i = 52;
The output on the screen:
printf("%d", i<25); // Output: 0 (False)
return 0;
Enter any number: }
If you enter the number 3
Enter any number:
If you enter the number 2
The remainder of a and b = 1 will be outputted on the screen.
If the statement:
printf("The remainder of a and b = %d", c);
135
is replaced by the statement:
printf("The remainder of %d and %d = %d", a, b, c);
• Program 3.2
C program to check the equivalence of two numbers.
if(x-y==0) }
{
136
The output on the screen:
Access Modifier:
Since 2−2 is equal to 0 (i.e., x−y == 0).
Therefore: the statement: An expression in Java that specifies if or how a
{
class member can be accessed. Public, private,
printf("The two numbers are equivalent"); protected, static, and final are examples of
Since 3−2 is not equal to 0 (i.e., x−y != 0). Therefore: the statement:
{ Dispatch
printf("The two numbers are not equivalent");
}
137
(As said earlier: in C language the symbol != implies not equal to)
return 0;
}
Answer:
There is no mistake in the above program. The output on the screen is:
Leap year
The statement:
printf("Leap year");
1995 divided by 4 (i.e., year divided by 4) yields the remainder not equal to 0.
The statement:
138
printf("Not a leap year");
Note: for a year to be leap year, year divided by 4 should yield remainder = zero.
− Donald Knuth
Local variables:
Variable whose existence is known only to the main program or functions are called
local variables. Local variables are declared within the main program or a function.
Global variables:
Variables whose existence is known to the both main() as well as other functions are called
global variables. Global variables are declared outside the main() and other functions.
#include<stdio.h>
int x=1; → global variable
int main()
{
int y=3; → local variable
}
#include <stdio.h>
int main () {
139
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
printf("Greeting message: %s\n", greeting );
return 0;
}
#include <stdio.h>
char x[50];
#include <stdio.h>
#define LENGTH 10 int main() {
• Program 3.3
C program to print whether the given number is positive or negative
#include <stdio.h>
int main() {
#include<stdio.h>
puts("Enter a character: ");
int main()
puts("To stop, press # and then Enter.");
{
for(;;) {
int a;
a = -35; char x=getchar();
if(a>0) if(x=='#') {
{ break;
printf("Number is positive"); }
} }
else Output:
printf("......!\n");
{
return(0); Enter a character:
printf("Number is negative");
} To stop, press # and then Enter.
}
A # entered character
return 0;
B # entered character
}
# # entered character
......!
140
The output on the screen:
Number is negative
Since a = −35. Therefore: a is less than 0 i.e., a < 0 because any negative number is always
less than zero.
Language standard
The statement:
Rules governing what constitutes valid
printf("Number is negative"); code in a specific language and what a
compiler or interpreter must ensure for
how this is carried out
is executed to print the output:
Number is negative
• Program 3.4
C program to print the sum of the first 10 digits using for loop statement
#include <stdio.h>
#include<stdio.h> int main() {
int main()
int x, y;
{
printf("Enter a number: ");
int i, sum = 0;
scanf("%d", &x);
for( i=1; i<=10; i++)
sum = sum + i; printf("Enter a number: ");
141
sum of the first 10 digits = 55
▪ How the sum of the first 10 digits = 55 is outputted on the screen through the for
Loop statement?
i=1 (sum = 0 because the sum is initialized to 0 in the statement int i, sum = 0;)
Is i<=10 true?
Yes, do this
#include <stdio.h>
142
Yes, do this
sum = sum + i = 21 + 7 = 28
#include <stdio.h>
Now,
int main() {
i=8 (sum = 28)
Is i<=10 true? for(int i=90; i != 55; i -= 5) {
If the statement:
int i, sum = 1;
143
Then the output on the screen is:
sum of the first 10 digits = 56
▪ What will be the output if the for loop statement for(i =1; i<=10; i++) is replaced
bythe statement for(i =2; i<10; i++)?
#include <stdio.h>
Answer: sum of 10 digits = 44
int main() {
int a = 15;
If the statement: for(int b=10; b != a; b++) {
printf("%d\n", b);
int i, sum, sum = 0; } Output:
return 0;
10
}
11
is written instead of:
12
13
int i, sum = 0;
14
Then the compilation error message will be displayed on the screen (stating that sum is
twice declared).
• Program 3.5
C program to print the average of the first 10 numbers using for loop statement
#include<stdio.h>
int main()
{
144
int i, avg, sum = 0;
for( i=1; i<=10; i++)
sum = sum + i;
avg = sum/10;
printf("sum of the first 10 numbers =%d", sum);
printf("average of the first 10 numbers =%d", avg);
return 0;
}
The average of the first 10 numbers = 55/10 = 5.5 not 5. But the output on the screen is:
#include <stdio.h>
If the data type float is used i.e.,
int main() {
int x=1;
#include<stdio.h>
int main() while(x<3) {
{ printf("Hi..\n");
x++;
float i, avg, sum = 0;
for( i=1; i<=10; i++) sum }
= sum + i; return(0);
avg = sum/10; }
145
• Program 3.6
C program to print the product of the first 10 digits using for loop statement
#include<stdio.h>
int main()
{
int i, product = 1;
for( i=1; i<=10; i++)
product = product * i;
printf("The product of the first 10 digits =%d", product);
return 0;
}
▪ How the product of the first 10 digits = 3628800 is outputted on the screen through
the for Loop statement?
146
Now,
#include <stdio.h>
i=4 (product = 6)
int main() {
Is i<=10 true?
char x = '\0';
Yes, do this
printf("Enter a character: \n");
product = product * i = 6 * 4 = 24
Now, for( ; ; ) {
i=5 (product =24) x = getchar(); /* get a character */
Is i<=10 true? if(x == 'b')
Yes, do this break; /* exit the loop */
product = product * i = 24 * 5 =120 }
Now,
printf("You have entered 'b'");
i=6 (product =120)
return 0;
Is i<=10 true?
}
Yes, do this
product = product * i = 120 * 6 = 720
Now, // Output:
i=7 (product =720) Enter a character:
Is i<=10 true? a # entered character
Yes, do this c # entered character
product = product * i = 720 * 7 = 5040 b # entered character
Now,
You have entered 'b'
i=8 (product =5040)
Is i<=10 true?
Yes, do this
#include <stdio.h>
product = product * i = 5040 * 8 = 40320
Now, int main() {
147
The statement:
printf("The product of the first 10 digits =%d", product); is executed to display ….the output:
The product of the first 10 digits = 3628800
• Program 3.7
C Program to print the table of a number using the for loop statement
#include<stdio.h>
int main()
{
Forwards compatibility:
int n, i;
148
The output on the screen:
▪ How the execution takes its Way through the for Loop statement
Now,
i=2
Is i<=5 true?
Yes, print this
2 * 2 = 4
using the statement printf("%d * %d = %d\n", n, i, n*i);
Now,
i=3
Is i<=5 true?
Yes, print this
2 * 3 = 6
using the statement printf("%d * %d = %d\n", n, i, n*i);
Now,
149
i=4
Is i<=5 true?
Yes, print this
2 * 4 = 8
using the statement printf("%d * %d = %d\n", n, i, n*i);
Now,
i=5
Is i<=5 true?
Yes, print this
2 * 5 = 10
using the statement printf("%d * %d = %d\n", n, i, n*i);
#include <stdio.h>
int main() {
printf("%.4f\n", 549.9876545321);
If the symbol * is replaced by +
// Output: 549.9877
i.e.,
printf("%3.8d\n", 5000);
#include<stdio.h>
// Output: 00005000
int main()
printf("%10.15s\n", "Alan Mathison Turing");
{
// Output: Alan Mathison T
int n, a;
return 0;
printf("Enter any number:"); }
scanf("%d", &n);
for( i=1; i<=5; i++)
Then the output on the screen is: Examining the time the code spends
to find performance problems and
Enter any number:
potential improvement areas
If you enter the number 2 (i.e., n=2)
2 + 1 = 3
2 + 2 = 4
2 + 3 = 5
150
2 + 4 = 6
2 + 5 = 7
Sideways compatibility:
will be outputted on the screen.
An assurance that code will remain to be
compatible with other code
• Program 3.8
C program:
#include <stdio.h>
If you enter a character M
#include <string.h>
Output must be: ch = M
int main() {
#include<stdio.h>
if(strchr("albert", 'l'))
int main()
{ printf("l is in 'albert'\n");
char M;
// Output: l is in 'albert'
printf("Enter any character:");
scanf("%c", &M); if(strstr("alan turing", "ring"))
printf("ch=%c", M);
printf("Found ring");
return 0;
} // Output: Found ring
return 0;
}
The output on the screen:
Enter any character:
If you enter the character M
ch = M will be outputted on the screen.
• Note:
scanf("%c", &M);
151
by the statement:
M = getchar();
#include <stdio.h>
int main() {
printf("%*.*f\n", 10, 2, 5496.85577);
i.e., printf("%*.*f\n", 20, 3, 5496.85577);
return 0;
#include<stdio.h> }
int main()
{
// Output:
char M;
printf("Enter any character:");
M = getchar(); 5496.86
There will be no change in the output on the screen i.e., the output on the screen is:
Enter any character:
If you enter the character K
ch = K will be outputted on the screen.
#include <stdio.h>
int main() {
printf("ch=%c", M);
printf("%d ", x);
printf("\n");
printf("x : %d", x);
by the statement: return 0;
}
putchar (M);
// Output:
i.e., 0 1 2 3 4
#include<stdio.h> x : -5
152
int main()
{
char M;
printf("Enter any character:");
scanf("%c", &M);
putchar (M);
return 0;
}
Then there will be no change in the output on the screen i.e., the output on the screen is:
Enter any character:
If you enter the character M
M will be outputted on the screen. #include <stdio.h>
int main() {
If you replace the statement: int i = 100;
scanf("%c", &M); int *x, *y;
x = &i;
y = x;
by the statement: /* print the value of 'i' twice */
printf("%d %d\n", *x, *y);
M = getchar();
return 0;
}
and the statement
printf("ch=%c", M);
// Output: 100 100
by the statement:
putchar (M);
i.e.,
#include<stdio.h>
int main()
{
char M;
printf("Enter any character:");
M = getchar();
153
putchar (M);
return 0;
}
• Program 3.9
C program to print the first 5 numbers starting from one together with their squares.
#include<stdio.h>
int main()
{
int i;
for( i=1; i<=5; i++)
printf("number=%d its square=%d\n", i , i*i);
return 0;
#include <ctype.h>
}
#include <stdio.h>
int main() {
printf("Enter a character: \n");
The output on the screen:
for(;;) {
char x = getchar();
number=1 its square=1
if(x == '#') break;
number=2 its square=4
if(isalnum(x)) printf("%c is alphanumeric\n", x);
number=3 its square=9
}
number=4 its square=16
Output:
number=5 its square=25 return 0;
Enter a character:
}
b # entered character
b is alphanumeric
▪ How the execution takes its way through the for loop statement 1 # entered number
1 is alphanumeric
i=1 # # entered character
154
Is i<=5 true?
Yes, print this
number=1 its square=1
using the statement printf("number=%d its square=%d\n", i , i*i);
Now,
i=2
Is i<=5 true?
Yes, print this
number=2 its square=4
using the statement printf("number=%d its square=%d\n", i , i*i);
Now,
i=3
Is i<=5 true?
Yes, print this
number=3 its square=9
using the statement printf("number=%d its square=%d\n", i , i*i);
Now,
i=4
Is i<=5 true?
Yes, print this
number=4 its square=16
using the statement printf("number=%d its square=%d\n", i , i*i);
Now,
i=5
Is i<=5 true?
Yes, print this
number=5 its square=25
using the statement printf("number=%d its square=%d\n", i , i*i);
▪ Note:
If the statement
155
printf("number=%d its square=%d\n", i , i*i);
#include <stdio.h>
Then the output on the screen is:
#include <string.h>
int main() {
number=1 its square=1
char x[80];
number=2 its square=4
printf("Enter a string: \n");
number=3 its square=9
fgets(x, 10, stdin);
number=4 its square=16
printf("%s", x);
number=5 its square=25
return 0;
} Output:
Enter a string:
alan turing # entered string
alan turi # output
tab "/t" is included because to leave space between
Suppose
printf("number=%d its square=%d", a , a*a);
156
number=1 #include <stdio.h>
its square=1 int main() {
number=2 int i, *x, **y;
its square=4 i = 55;
number=3
x = &i;
its square=9
y = &x;
number=4
/* print the value of i */
its square=16
printf("%d", **y);
number=5
its square=25 // Output: 10
return 0;
}
by the statement:
i.e., if you place variable separator (i.e., comma) between number=%d\n and its square=%d\n
• Write a program to print the first 10 numbers starting from one together with their
squares and cubes?
Answer:
#include<stdio.h>
int main()
157
{
int i;
for( i=1; i<=10; i++)
printf("number=%d its square=%d its cube=%d\n", i , i*i, i*i*i);
return 0;
}
no-op:
Pointer Code that does nothing
A variable that can hold the address of other variables, arrays, structures, unions and functions that are used
in the C program. It contains only the memory location of the variable rather than its content. The purpose of
pointer is to save memory space and achieve faster execution time.
Breakpoint
Advantages:
(Break execution)
158
Operators used with pointers
The address operator gives the address of a variable while the indirection operator gives
the value of the variable that the pointer is pointing to.
Suppose x is a variable that holds data of type int. We can access the address of x
through an address operator [&]. This address can be stored in some variable [say y].
Thus we can relate x and y as:
"y = &x"
y is called a pointer variable because it holds the address of another variable [i.e.,
x] but not the actual value of x.
There are two integer variables 100 and 640 stored respectively at memory locations
1000 and 1003. Let us assign:
x = 100; y = 640;
In order to access the value of a variable 'x' via pointer, we must need a variable.
Assume that variable be px. The following statement assigns the address of 'x' to px:
In order to access the value of a variable 'y' via pointer, we must need a variable.
Assume that variable be py. The following statement assigns the address of 'y' to py:
x and y are integer variables. The asterisk that appears before px and py indicates
159
#include <stdio.h>
#include <stdio.h> int main() {
int main() { int x = 5;
struct {
int x; char names[][12]={
int y; "Albert",
} a, b; "Alan",
"John",
a.x = 56; "James",
b = a; /* assign one structure to another */ "Mary",
printf("%d", b.x); "David"
return 0; };
}
printf("%s", names[x]);
// Output: 56 // Output: David
return 0;
}
• Program 4.0
C program to print the sum of two numbers using pointers
within the body of the main function int main() − this variable is stored in the computer
memory i.e., this variable occupies a specific location in the space of computer memory. And
this integer variable x is assigned an address (i.e., &x) to locate its position in the computer
memory (like a house in the street is assigned an address to locate its position in
the street). Pointers are the variables that represent the address of x in the computer memory
i.e., p = &x, where &x imply the address of x in the computer memory and p is the pointer
variable (which is the variable that represent the address of x in the computer memory ).
And further if you assign a value to the variable x by declaring the statement:
x=1;
160
within the body of the main function — this value is stored in the address of x in the computer
memory. "*" denote pointer operator and *p denote the pointer (which represent the value
stored in the address of x in the computer memory).
C++ Program:
#include <stdio.h>
#include<iostream>
int main()
using namespace std;
{
int main() {
int x, *p;
int x, y, z, sum;
x = 1;
for ( ; ; ) {
p = &x;
cout << "Enter x, y and z: "<< endl;
printf("The address of the variable x =%d", p);
cin >> x >> y >> z;
printf("The value of the variable x =%d", *p);
if(!cin)
return 0;
break;
}
sum = x + y + z;
cout << "x + y + z = " << sum << endl;
}
cout <<".......\n";
The output on the screen: }
The value of the variable x = 1 because you have assigned a value to the variable x by
declaringthe statement:
x=1;
161
within the body of the main function. Minimum working example:
printf("The address of the variable x =%d and its value =%d", p,*p);
i.e.,
Code path:
#include <stdio.h>
The path used by the program's
int main()
source code when it runs
{
int x, *p;
x=1;
p = &x;
printf("The address of the variable x =%d and its value =%d", p,*p);
return 0;
}
#include <stdio.h>
int main()
{
int x, y, *p, *q, sum;
printf("Enter any number:");
162
scanf("%d", &x);
printf("Enter any number:");
#include <stdio.h>
scanf("%d", &y);
#define MAX 55
p = &x;
q = &y; int main() {
// Output:
Enter any number:
85>55
If you enter the number 2
Enter any number:
If you enter the number 3
Sum of entered numbers = 5 will be outputted on the screen.
Since pointer *p imply the value assigned to the variable x (i.e., 2) through the keyboard
and the….pointer *q imply the value assigned to the variable y (i.e., 3) through the keyboard.
Therefore: sum = *p + *q = 2 + 3 = 5 (which will be outputted on the screen).
• C program to print the product, subtraction and division of two numbers using
pointers
MoSCoW method:
#include <stdio.h>
A technique for prioritizing where
int main() criteria are categorized into elements that
{ frequently occur in a certain iteration of a
int x, y, *p, *q, product, subtract, div;
piece of code and are thus regarded as
printf("Enter any number:");
such include elements that Must, Should,
scanf("%d", &x);
printf("Enter any number:");
Could, and Won't be done
scanf("%d", &y);
163
p = &x;
#include <stdio.h>
q = &y;
int main() {
product = *p * *q;
int i, x = 1;
subtract = *p - *q;
for (i = 1; i <= 5; i++)
div= *p / *q;
printf("product of entered numbers = %d\n", product); printf("%d", i & x);
printf("subtract of entered numbers = %d\n", subtract); // Output: 10101
printf("division of entered numbers = %d\n", div); return 0;
return 0; }
}
#include <stdio.h>
#include<stdio.h>
#define mkstr(x) # x
int main()
int main() {
{
printf(mkstr(Albert));
int x, y, *p, *q;
printf("Enter any integer:"); // Output: Albert
scanf("%d", &x); return 0;
printf("Enter any integer:"); }
scanf("%d", &y);
p = &x;
q = &y;
164
if(*p>*q)
#include <ctype.h>
{
#include <stdio.h>
printf("x is greater than y");
} int main() {
if(*q>*p) printf("Enter a character: \n");
{ for(;;) {
printf("y is greater than x"); char x = getchar();
} if(x == '#') break;
return 0;
if(isdigit(x)) printf("%c is a digit\n", x);
}
}
return 0;
} Output:
The output on the screen: Enter a character:
J # entered character
2 # entered number
Enter any integer:
2 is a digit
If you enter the integer 10
# # entered character
Enter any integer:
If you enter the integer 16
165
Alan M Turing
ii)
#include <stdio.h>
#include <stdio.h> #include <string.h>
int main() int main() {
{ char *x;
int x, t, c;
x = strchr("This is my book.", ' ');
x =12;
printf("%s", x);
t = 2;
return 0;
c = x/t;
}
printf("velocity = %d m/s", c);
return 0;
} // Output: is my book.
Answer:
velocity = 6 m/s
• Program 4.1
#include<stdio.h>
int addition();
int main() Input sanitation
{
int answer;
answer = addition();
printf("The sum of two numbers is: %d\n", answer); Eliminate invalid characters from input
return 0;
}
int addition()
{
int x, y;
printf("Enter any integer:");
166
C Program:
scanf("%d", &x);
printf("Enter any integer:");
scanf("%d", &y);
#include <stdio.h>
return x+y;
} #include <stdlib.h>
int main()
{
The output on the screen: int a=6, b=2;
printf("%d", a+(~b)+1);
Enter any integer: return 0;
If you enter the integer 3 }
Enter any integer:
If you enter the integer 5
The sum of two numbers = 8 will be displayed on the screen.
Output:
4
Java Program:
public class HelloWorld {
public static void main(String[] args) {
public class HelloWorld {
while(true) {
public static void main(String[] args) {
System.out.println("infinite while loop");
int x = 0;
}
while (true) {
}
System.out.println("\n " + x++);
}
if (x == 4)
break;
}
Output: Output:
}
} 0
infinite while loop
1 infinite while loop
Cyber Analytics: An approach for identifying potential vulnerabilities and minimizing harm
from existing cyberthreats that combines concepts of cybersecurity and data science
167
int addition();
int means integer and int addition() implies: addition() should return integer value.
int addition()
The function to add the entered values (i.e., 3 and 5) and return the result (i.e., 3 +
5 i.e., 8) to the statement:
printf("The sum of two numbers = %d", answer); to
make provision to display the output:
{
int x, y;
printf("Enter any integer:");
scanf("%d", &x);
printf("Enter any integer:");
scanf("%d", &y);
return x+y;
}
answer = addition();
addition()
to add the entered values (i.e., 3 and 5) and return the result (i.e., 3 + 5 i.e., 8)
to the statement:
168
printf("The sum of two numbers = %d", answer);
on the screen.
In the statement:
The format string " %d" indicates that the value to be displayed at that point in
thestring i.e., after the statement:
needs to be taken from the result returned by the function int addition().
#include<stdio.h>
int multiplication();
int main()
{
int answer;
answer = multiplication();
printf("The product of two numbers is: %d\n", answer);
return 0;
}
int multiplication()
{
int x, y;
169
printf("Enter any integer:");
scanf("%d", &x);
printf("Enter any integer:");
scanf("%d", &y); #include <math.h>
return x*y; #include <stdio.h>
}
int main() {
printf("%1.1f %1.1f", fabs(2.0), fabs(-2.0));
return 0;
}
The output on the screen:
// Output: 2.0 2.0
Enter any integer:
If you enter the integer 3
Enter any integer:
If you enter the integer 5
The product of two numbers = 15 will be outputted on the screen.
#include<stdio.h>
int largest();
int main()
{
int answer;
answer = largest();
printf("The largest of two numbers is: %d\n", answer);
return 0;
} #include <stdio.h>
#define PUT(x) printf("Albert\n");
int largest() int main() {
{
PUT(Hi from main());
int x, y;
return 0;
printf("Enter any integer:");
}
scanf("%d", &x);
printf("Enter any integer:");
scanf("%d", &y); // Output: Albert
170
if(x>y)
#include <stdio.h>
return x;
int main() {
if(y>x)
char x[] = "Ilbert";
return y;
char *z = x;
}
*z = 'A';
printf("%s\n", x);
}
The output on the screen:
// Output: Albert
171
if(x>y&& x>z)
return x;
#include <math.h> x = Mantissa × 2Exponent
#include<stdio.h>
#include <stdio.h>
int square();
int main() {
int main()
printf("Albert \"Einstein\"!\n");
{
// Output: Albert "Einstein"!
172
#include <stdio.h>
printf("Enter any integer:");
int main() {
scanf("%d", &x);
char *x = "alan", *y = "alan";
return x*x;
if (x == y)
}
printf("The 2 strings have the same address\n");
else
printf("The 2 strings have the different address\n");
The output on the screen is: return 0;
}
// Output: The 2 strings have the same address
Enter any integer:
If you enter an integer 5
Square of the number = 25 will be outputted on the screen.
#include<stdio.h>
{ int main() {
double i;
int x=6;
for(i=2.0; i<1.0e+10; i=i*10)
printf("The address of x = %d", &x);
printf("%g ", i);
return 0; return 0;
} }
Answer:
The address of x = 343441332
# Output:
• Program 4.2 2 20 200 2000 20000 200000 2e+06 2e+07 2e+08 2e+09
If-else statement provides a way for selecting any one of the 2 possible alternatives. And,
nested- if allow us to select one of the many alternatives but it is time consuming. To overcome
this, the switch case statement is used. Switch (case) allows the user to make decision from the
number of choices i.e., from the number of cases.
173
For example:
174
switch(ch) allow us to make decision from the number of choices i.e., from the number of
cases
case 'R':
case 'W':
case 'Y':
case 'G':
printf("Red"); print(a)
print('Dimensions of array:', a.ndim)
Error
case 'R':
Datadog
case 'W':
case 'Y':
An effective cloud monitoring service that uses a
case 'G':
SaaS based platform to examine activities in any
Therefore the statement:
infrastructure, database, or application at any
printf("Error"); scalability
175
is executed to display the output:
Error
on the screen).
The break statement denotes the end of a particular case and thereby the switch statement is
terminated. The case default is executed, when the value of an expression is not matched with
any of the cases.
If the statements:
case 'R':
printf("Red");
break; Coffman's conditions that cause a deadlock:
case 'W':
• Mutual Exclusion: A crucial resource can only be used by one
printf("White");
break; process at a time
case 'Y': • Hold and Wait: Some resources may be allocated to a process
printf("Yellow"); while others are being waited for
break; • No Pre-emption: No resource can be forcibly taken from a process
case 'G': that is holding it
printf("Green"); • Circular Wait: Each process in a closed chain of processes retains
break;
at least one resource required by another process in the chain
default:
printf("Error");
break;
#include <stdio.h> #include <stdio.h>
int main() { int main() {
are replaced by the statements:
float x=0.2d; float x=0.2d;
if(x>0.9) { if(x<0.9) {
case 'R':
printf("Albert"); printf("Albert");
printf("Red");
} }
case 'W':
else { else {
printf("White");
printf("Einstein"); printf("Einstein");
case 'Y':
} }
printf("Yellow");
return 0; return 0;
break;
} }
case 'G':
Output: Output:
printf("Green");
break;
Einstein Albert
176
Terraform
default:
printf("Error");
break;
An open source infrastructure orchestration
tool that automates the deployment and
management of infrastructure
Then the output on the screen is:
Red
White
Yellow
i.e., the output will be printed till yellow even though you have entered the character R.
177
Arrays
ldexp(3,4) = 3 × 24 = 3 × 16
using arrays:
ldexp(3,4) = 48.000000
#include<stdio.h>
int main()
{
178
int i;
int num [5] = {16, 18, 20, 25, 36};
for(i=0; i<5; i++)
printf("\n Element [%d] = %d", i, num[i]);
return 0;
} #include <stdlib.h>
#include <stdio.h>
The output on the screen:
int main() {
The statement:
int num [5] = {16, 18, 20, 25, 36};
imply that we are creating an integer array (and the name of array is num) consisting of 5
values(i.e., 16, 18, 20, 25, 36) of the same data type int.
The number of values between the braces { } cannot be larger than the number of values that
wedeclare for the array between square brackets [ ].
There are 5 integers i.e., 16, 18, 20, 25, 36 within the braces { }, so 5 is written within the
squarebrackets [ ].
If there were 6 integers i.e., 16, 18, 20, 25, 36, 42 within the braces { }, then 6 must be
written…within the square brackets [ ].
▪ Note: With the declaration int num [5], computer creates 5 memory cells with
name num[0], num[1], num[2], num[3], num[4].
179
And since:
the values 16, 18, 20, 25, 36 are stored in num[0], num[1], num[2], num[3], num[4] respectively.
▪ How the execution takes its way through the for loop statement?
i=0
Is i<5 true?
Yes, print this
Element [0] = 16
using the statement:
printf("\n Element [%d] = %d", i, num[i])
format string %d in the square brackets indicates that the value to be displayed at
that point in the string i.e., within the square brackets [ ] needs to be taken from a
variable (which is i i.e., i=0) and the format string %d after the statement (\n
Element [%d] = ) indicates that the value to be displayed at that point in the string
i.e., after the statement (\n Element [%d] = ) needs to be taken from a variable (which
is stored in num[i] i.e., num[0] i.e., 16).
Now,
i=1
Is i<5 true?
Yes, print this
Element [1] = 18
using the statement:
printf("\n Element [%d] = %d", i, num[i])
format string %d in the square brackets indicates that the value to be displayed at
that point in the string i.e., within the square brackets [ ] needs to be taken from a
variable (which is i i.e., i=1) and the format string %d after the statement (\n
Element [%d] = ) indicates that the value to be displayed at that point in the string
i.e., after the statement (\n Element [%d] = ) needs to be taken from a variable (which
is stored in num[i] i.e., num[1] i.e., 18).
Now,
i=2
180
Is i<5 true?
Yes, print this
Element [2] = 20
using the statement:
printf("\n Element [%d] = %d", i, num[i])
format string %d in the square brackets indicates that the value to be displayed at
that point in the string i.e., within the square brackets [ ] needs to be taken from a
variable (which is i i.e., i=2) and the format string %d after the statement (\n
Element [%d] = ) indicates that the value to be displayed at that point in the string
i.e., after the statement (\n Element [%d] = ) needs to be taken from a variable (which
is stored in num[i] i.e., num[2] i.e., 20).
Now,
i=3
Is i<5 true?
Yes, print this
Element [3] = 25
using the statement:
printf("\n Element [%d] = %d", i, num[i])
format string %d in the square brackets indicates that the value to be displayed at
that point in the string i.e., within the square brackets [ ] needs to be taken from a
variable (which is i i.e., i=3) and the format string %d after the statement (\n
Element [%d] = ) indicates that the value to be displayed at that point in the string
i.e., after the statement (\n Element [%d] = ) needs to be taken from a variable (which
is stored in num[i] i.e., num[3] i.e., 25).
Now,
i=4
Is i<5 true?
Yes, print this
Element [4] = 36
using the statement:
printf("\n Element [%d] = %d", i, num[i])
Stop because the condition i<5 is achieved.
Format string %d in the square brackets indicates that the value to be displayed at that point in
the string i.e., with the square brackets [ ] needs to be taken from a variable (which is i i.e., i=4)
181
and the format string %d after the statement (\n Element [%d] = ) indicates that the…value
to be displayed at that point in the string i.e., after the statement (\n Element [%d] =
) needs to be taken from a variable (which is stored in num[i] i.e., num[4] i.e., 36).
182
Element [1] = 18
#include <stdio.h>
Element [2] = 18
int main() {
Element [3] = 18
printf("A%cl%ca%cn\n", '\0', '\0', '\0') ;
Element [4] = 18
return 0;
}
// Output: Alan
Suppose the statement:
#include <stdio.h>
Suppose the statement:
int main() {
int x;
printf("\n Element [%d] = %d", i, num[i]);
do {
printf("Enter a number: \n");
scanf("%d", &x);
is replaced by the statement: }
while(x<1 || x>100);
printf("\n Element [%d] = %d", i, num[3]); return 0;
}
Enter a number:
The output on the screen: 0 # entered number
Enter a number:
Element [0] = 25 101 # entered number
Enter a number:
2 # entered number
183
Element [1] = 25
Element [2] = 25
Element [3] = 25
Element [4] = 25
If the condition:
i<5
▪ 3656 is the number stored in the memory i.e., any number stored in the memory will be
displayed.
184
If the statement:
int num [5] = {16, 18, 20, 25, 36}; is replaced by the statement:
int num [i] = {16, 18, 20, 25, 36};
Then the compilation error will be displayed on the screen because there are 5 elements within
the braces {} not i elements.
• Note:
▪ How the Execution takes its way through the for loop statement?
i=0 (sum = 0)
Is i<5 true?
Yes, do this
sum = sum + num[i] = sum + num[0] = 0 +16 =16
185
Now,
#include <stdio.h>
i=1 (sum = 16)
int main() {
Is i<5 true?
int a, b, c;
Yes, do this
int x=0;
sum = sum + num[i] = sum + num[1] = 16 +18 =34
if(x==0) {
Now, a = 12;
i=2 (sum = 34) b = 13;
Is i<5 true? c = 15;
Yes, do this }
sum = sum + num[i] = sum + num[2] = 34 +20 =54
else {
a = -11;
Now,
b = -12;
i=3 (sum = 54)
c = -13;
Is i<5 true?
Yes, do this }
sum = sum + num[i] = sum + num[3] = 54 +25 =79 printf("%d", a + b + c);
return 0;
Now, }
i=5 (sum = 79)
Is i<5 true?
// Output: 40
Yes, do this
sum = sum + num[i] = sum + num[5] = 79 + 36 =115
stop because the condition i<5 is achieved
The statement:
printf("Sum of the Elements in the array = %d", sum); is executed to display the
output:
Sum of the Elements in the array = 115
on the screen.
If the statement:
int i, sum = 0;
is replaced by int i, sum = 1;
Then The output on the screen:
Sum of the Elements in the array = 116
186
#include<stdio.h>
int main()
{
int i, avg, sum = 0;
int num [5] = {16, 18, 20, 25, 36};
for(i=0; i<5; i++)
sum = sum + num [i];
avg = sum/5;
printf("Sum of the Elements in the array = %d", sum);
printf("average of the elements in the array= %d", avg);
return 0;
}
Element [0] = E
#include <stdio.h>
Element [1] = I
int main() {
Element [2] = N
int x = 20+/* add the 2 numbers */50;
Element [3] = S printf("%d", x);
Element [4] = T // Output: 70
Element [5] = E return 0;
Element [6] = I }
Element [7] = N
using arrays
187
Answer:
#include<stdio.h>
int main()
{
int i;
char name [8] = {' E' , ' I', ' N', ' S', ' T ', ' E', ' I', ' N'};
for(i=0; i<8; i++)
printf("\n Element [%d] = %c", i, name[i]);
return 0;
}
• Note:
#include <stdio.h>
Then the output on the screen is:
int main() {
Element [69] = E int i = 0, x = 16;
Element [73] = I while ((x /= 2) > 0)
Element [78] = N printf("%-6d", x);
Element [83] = S return 0;
Element [84] = T }
Element [69] = E
Element [73] = I // Output:
Element [78] = N 8 4 2 1
188
i)
#include <stdio.h>
#include <stdio.h> int main() {
#include <math.h> printf("\"Albert\"");
int main()
return 0;
{
}
printf("%f", cbrt(27));
return 0;
}
// Output: "Albert"
#include <stdio.h>
Answer:
int main() {
3.000
printf("%cAlbert%c", '\'', '\'');
return 0;
ii) }
#include <stdio.h>
int main()
// Output: 'Albert'
{
char i;
char body [4] = {'b', 'o', 'd', 'y'};
#include <stdio.h>
for(i=0; i<4; i++)
printf("\n body[%c] = %c", body[i] , body[i]); int main() {
return 0; printf("%cAlbert%c", '\"', '"');
} return 0;
}
// Output: "Albert"
Answer:
#include <stdio.h>
body [b] = b
body [o] = o int main() {
body [d] = d printf("\'Albert'");
body [y] = y return 0;
}
189
#include <malloc.h>
C++ program:
int main()
{
#include <iostream>
int x=2;
using namespace std;
printf("%d", malloc(200*sizeof(x)));
int main(int argc, char **argv) {
return 0;
cout << 16u - 2;
}
return 0;
}
Output:
Answer: 8183824
14
Law of Increasing Complexity:
Java Program:
Answer: There is no mistake in the above program. The output on the screen is:
190
• Program 4.3
C program to print the output: #include <iostream>
using namespace std;
int main(){
Name of the book = B
extern int x;
Price of the book = 135.00
cout<< x <<endl;
Number of pages = 300
return 0;
Edition of the book = 8
} int x = 55; Output:
55
using structures
#include<stdio.h>
int main() #include <iostream>
{ using namespace std;
struct book { void myfunc(int& x, int& y, int& z) {
char name; x *=6;
float price; y *=4;
int pages; z *=3;
int edition; }
}; int main() {
int p = 11, q = 12, r = 15;
struct book b1; myfunc(p, q, r);
b1.name = 'B'; cout<<" "<<p<<"\n "<<q<<"\n "<<r;
b1.price = 135.00; return 0;
b1.pages = 300; } Output:
b1.edition = 8; 66
printf("\n Name of the book = %c", b1.name); 48
printf("\n Price of the book = %f", b1.price);
45
printf("\n Number of pages = %d", b1.pages);
printf("\n Edition of the book = %d", b1.edition);
return 0;
#include <iostream>
}
using namespace std;
int main() {
int x=11, y=13, z;
Output:
z=(x>y) ? x : y;
The output on the screen: cout<<z; 13
return 0;
}
191
Name of the book = B
Price of the book = 135.00 #include <iostream>
Number of pages = 300 using namespace std;
Edition of the book = 8 int myfunc(int x, int y=2) {
int z;
z = x * y; Output:
a statement: return z; 32
The
}
72
struct book {
int main() {
char name;
cout<<myfunc(16);
float price;
cout<<"\n"; cout<<myfunc(8,9);
int pages;
return 0;
int edition;
}
};
imply the structure definition i.e., we are defining a structure (and the data type name of the structure is book) and
it consists of elements:
▪ name (which is of data type char), price (which is of data type float), pages (which is of data type int),
edition (which is of data type int) – which are placed within the body of the structure.
Java program:
The statement: import java.util.Arrays;
Denote the structure variable import java.util.LinkedHashSet;
import java.util.Set;
In order to assign the values to the elements within the body of the structure, each element must be linked with
structure variable with dot operator or period operator or member accessibility operator.
192
For example: name is the element which must be linked with structure variable b1
with dot operator to assign a value B to the element "name".
indicates that the value to be displayed at that point in the string i.e., after the statement "\n Name of the book = " needs
to be taken from b1.name.
The statement:
printf("\n Name of the book = %c", b1.name);
make provision to print the output: Name of the book = B on the screen
indicates that the value to be displayed at that point in the string i.e., after the statement "\n Price of the book = " needs
to be taken from b1.price.
The statement:
make provision to print the output: Price of the book = 135.00 on the screen
5 Einstein
using namespace std; public class MyClass {
Einstein
int main() { 6 public static void main(String[] args) {
Einstein
5 String x = "Albert Einstein";
float x=5.22222; Einstein
5 for(int i=0; i<= x.length(); i++)
cout << floor(x) << endl; Einstein
5.2222 System.out.println(x.substring(6)); Einstein
cout << ceil(x) << endl;
} Einstein
cout << trunc(x) << endl; Einstein
}
cout << round(x) << endl; Einstein
Einstein
cout << setprecision(5) << x;
Einstein
return 0;
Einstein
Law of Perceived Complexity: The additions
} Einstein
and deletions of the subsequent releases of an
Einstein
evolving program are statistically invariant during Einstein
its active life
193
Format string %d (corresponding to the data type int) in the statement:
printf("\n Number of pages = %d", b1.pages);
indicates that the value to be displayed at that point in the string i.e., after the statement "\n Number of pages = " needs
to be taken from b1.pages.
The statement:
make provision to print the output: Number of pages = 300 on the screen.
indicates that the value to be displayed at that point in the string i.e., after the statement "\n Edition of the book = " needs to
be taken from b1.edition.
The statement:
make provision to print the output: Edition of the book = 8 on the screen.
194
#include <iostream>
struct book { #include <random>
char name; using namespace std; Output:
float price; int main() { 3
int pages; int a=10, b=2,i; 9
int edition; int x = a - b + 1; 2
}; for (i=b; i<a; i++)
9
int main() {
int c = rand() % x + b;
7
{
struct book b1; cout<<c<<endl; 9
b1.name = 'B'; } 3
b1.price = 135.00; return 0; 5
b1.pages = 300; }
b1.edition = 8;
printf("\n Name of the book = %c", b1.name);
printf("\n Price of the book = %f", b1.price);
printf("\n Number of pages = %d", b1.pages);
printf("\n Edition of the book = %d", b1.edition);
}
#include<iostream>
#include<string>
using namespace std;
Output:
15
B)
for( ; ; ) {
printf("This loop will run forever.\n"); An aphorism that claims companies build systems
}
that reflect their own communication framework
return 0;
195
}
Law of Continuing Growth:
Answer:
To keep users comfortable during a program's
This loop will run forever. lifetime, its functional content must be
This loop will run forever. continuously updated
This loop will run forever.
This loop will run forever.
This loop will run forever.
This loop will run forever ............ continues
C) #include<bits/stdc++.h>
using namespace std;
#include<stdio.h>
int main()
int main()
{
{
char ch [5];
double PI = 3.14159;
printf("Enter the name: ");
cout << fixed << setprecision(3) << PI <<endl;
scanf("%s", &ch);
return 0;
printf( "The name you entered = %s", ch);
}
return 0;
} Output:
3.142
Answer:
public class MyClass {
public static void main(String[] args) {
Enter the name: char[] x = {'A', 'B', 'C', 'D', 'E', 'F',
Dennis # entered name 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
The name you entered = Denni will be outputted on the screen. 'U', 'V', 'W', 'X', 'Y', 'Z'};
for(int i=0; i<x.length; i++) {
Fundamental Law of Program Evolution: System.out.print(x[i]);
}
System.out.println();
Software development is governed by a dynamics that produces
} Java Program
statistically definable patterns and invariances − enabling the }
software process and system to self-regulate
// Output: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Instead of Dennis, only Denni will be displayed on the screen because of the statement
char ch [5];
196
The statement:
char ch [5];
char ch [5];
int main ()
{
string x = "Albert Einstein was a ";
is replaced by the statement string y = "German-born theoretical physicist.";
string z = x + y;
cout<<" "<< z;
char ch [6];
return 0;
}
197
for (i=1; i<=5; i++)
{
if (i==3)
#include<iostream>
{
using namespace std;
continue;
int main() {
}
int x = 12, y = 12;
int z = -( -x-y );
printf("%d\n ", i);
cout << z << endl;
}
return 0;
return 0;
}
} Output:
24
1 #include<iostream>
i = 1 Albert Einstein
Is the condition (i<=5) is true?
Yes because i=1
The statement printf("%d\n ", i); is executed to print the output:
1
Now, the value of i is:
i = 1+1 = 2
Is the condition (i<=5) is true?
Yes because i=2
The statement printf("%d\n ", i); is executed to print the output:
2
Now, the value of i is:
i = 2+1 = 3
198
Is the condition (i<=5) is true?
Yes because i=3
The statement printf("%d\n ", i); is not executed to print the output:
3
#include <iostream>
Because of the statement: using namespace std;
int a = 0;
if (i==3) int main() {
{ int a = 0;
continue; ::a = 11; Output:
} a = 12;
cout << ::a << ", " << a; 11, 12
// Execution skips // return 0;
}
Now, the value of i is:
i = 3 + 1 = 4
Is the condition (i<=5) is true?
Yes because i=4
The statement printf("%d\n ", i); is executed to print the output:
4
Now, the value of i is:
i = 4+1 = 5
Is the condition (i<=5) is true?
Yes because i=5
The statement printf("%d\n ", i); is executed to print the output:
5
and stop because the condition i<=5 is achieved.
#include <iostream>
using namespace std;
ii) namespace num { int a = 18; }
#include <stdio.h> int main() {
int main() cout << num::a << endl;
{ return 0;
Output:
int i; }
for (i=1; i<=5; i++) 18
{
if (i==3)
{
break;
199
#include<iostream>
}
using namespace std;
const char* name = "Albert";
printf("%d\n ", i);
int main() {
}
const char* name = "Einstein";
return 0;
cout << name;
}
return 0;
Output:
}
Einstein
Output on the screen:
1 #include <iostream>
2 using namespace std;
int main() {
int x=20; Output:
• Note: x=!x>54;
cout<<x; 0
i = 1 return 0;
Is the condition (i<=5) is true? }
Yes because i=1
The statement printf("%d\n ", i); is executed to print the output:
1
Now, the value of i is:
i = 1+1 = 2
Is the condition (i<=5) is true?
Yes because i=2
The statement printf("%d\n ", i); is executed to print the output:
2
Now, the value of i is:
i = 2+1 = 3
Is the condition (i<=5) is true?
Yes because i=3
The statement printf("%d\n ", i); is not executed to print the output:
200
for loop: for (i=1; i<=5; i++)
is immediately terminated (even before the condition i<=5 is achieved) and program
execution stops.
int i; } }
1
2 Law of Declining Quality:
Linux
i = 1
Is the condition (i<=5) is true?
Yes because i=1
The statement printf("\n %d ",i); is executed to print the output:
201
1
Now, the value of i is:
i = 1+1 = 2 Bookmark
Is the condition (i<=5) is true?
Yes because i=2
The statement printf("\n %d ",i); is executed to print the output:
A group of links to websites
2
Now, the value of i is: that are preserved in a web
i = 2+1 = 3 browser as shortcuts
Is the condition (i<=5) is true?
Yes because i=3
The statement printf("%d\n ", i); is not executed to print the output:
3
Rather
The statement printf("\n Linux"); is executed to print the output:
Linux
#include<stdio.h>
int main()
{
char ch = 'A';
202
char b = tolower(ch);
printf("Upper case letter %c is converted to lower case letter %c", ch, b);
return 0;
}
If you want to enter the character through the keyboard, then the above program should take
the form:
Enter any character:
C # entered character
#include<stdio.h>
Upper case letter C is converted to lower case letter c will be
int main() { outputted on the screen.
char ch;
printf("Upper case letter %c is converted to lower case letter %c", ch, b);
return 0;
}
#include <cstring>
# Output:
#include <iostream>
using namespace std; The first time a number appears in marchFirst1988 is at position 10
int main() {
char x[] = "0123456789";
char y[] = "marchFirst1988";
size_t z = strcspn(y, x);
if (z < strlen(y))
cout << " The first time a number appears in " << y << " is at position " << z;
else
cout << y << " doesn't include any numbers";
C++ program
return 0;
}
• Program 4.6
C program to convert the lower case letter to upper case letter
203
Mainframe computer:
return 0;
}
If you want to enter the character through the keyboard, then the above program should take the
form: import java.util.Scanner; Java program
public class MyClass {
public static void main(String args[]) {
#include<stdio.h>
Scanner keyboard = new Scanner(System.in);
int main()
System.out.println(keyboard.nextLine());
{
keyboard.close();
char ch;
Alan # entered string
}
printf("Enter any character:");
} Alan # Output
scanf("%c", &ch);
char b = toupper(ch);
printf("Lower case letter %c is converted to upper case letter %c", ch, b);
return 0;
} #include <stdio.h>
int main () {
int x = 55, y = 100;
printf("Maximum number: %d\n", ((x + y) + abs(x - y)) / 2);
printf("Minimum number: %d\n", ((x + y) - abs(x - y)) / 2);
Output on the screen: return 0;
}
Enter any character: Output:
h # entered character
Lower case letter h is converted to upper case letter H Maximum number: 100
will be outputted on the screen. Minimum number: 55
• Program 4.7
204
C program to test whether the entered character is upper case letter or not
#include<stdio.h>
int main() {
#include<stdio.h>
int a= 5, b = 5;
int main()
if (!(a ^ b))
{
printf("a = b");
char ch = 'a';
else
if(isupper(ch))
printf("a ≠ b");
printf("you have entered the upper case letter");
return 0;
else Output:
}
printf("you have entered the lower case letter");
return 0;
a=b
}
#include<stdio.h>
Output on the screen:
#include<string.h>
you have entered the lower case letter
int main() {
char x[] = "Albert";
If the statement: char y[] = "Alan";
int z = strcmp(x, y);
char ch = 'a'; is replaced by the statement:
if (z==0)
char ch = 'A';
printf("2 strings are equal");
Then the output on the screen is: else
printf("2 strings are not equal");
return 0;
you have entered the upper case letter }
Output:
• Program 4.8
C program to test whether the entered character is lower case letter or not
Motherboard
#include<stdio.h>
int main()
{
char ch = 'a';
if(islower(ch))
The computer's main circuit board
printf("you have entered the lower case letter");
205
Router
else
printf("you have entered the upper case letter"); A device that provides access to the
return 0; Internet by transferring data between
}
computer networks
Java Program:
public class HelloWorld {
public static void main(String[] args) {
public class HelloWorld {
System.out.println('t' + 'a' + 'b');
public static void main(String[] args) {
}
boolean flag=false;
}
if(flag) {
System.out.println("true");
Output:
}
311
else {
System.out.println("false");
}
The ASCII values of 't', 'a', 'b' are:
} t 116
}
a 97
b 98
Output:
false 116 + 97 + 98 = 311
• Program 4.9
C program to print the value of tan inverse x (i.e., the value of tan−1x)
#include<stdio.h>
#include<math.h>
int main()
{
206
int x = 20;
• Program 5.0
#include<math.h>
int main() x = "aLBert"
{ print(x.casefold())
int x,y; # Output: albert
x = 20;
y =20;
printf("The value of tan inverse x/y = %f", atan2(x, y));
return 0;
}
207
{
float x = 20.500000;
float y =20.799999;
printf("The remainder of %f divided by %f is %f", x, y, fmod(x, y));
return 0;
}
C++ Program:
• Program 5.2
#include <iostream>
C program to print the value of ~x
using namespace std;
int main() {
#include<stdio.h> int a;
int main() for(a=1;a<=4;a++) {
{
switch(a) {
int x, y;
case 1: cout<<a<<endl;
x = 205;
break;
y=~x;
printf("The value of y is:%d", y);
case 2: cout<<a<<endl;
return 0; break;
} case 3: cout<<a<<endl;
break;
case 4: cout<<a<<endl;
y= -(~x);
208
Then the output on the screen is:
The value of y is: 206
• Program 5.3
C program to print the ASCII (American Standard Code for Information Interchange)
value of the entered character
Python code:
#include<stdio.h>
int main() x = 'albert einstein'
{
char ch ='A';
# print the number of occurrence of 'e'
printf("The ASCII value of ch is: %d", ch);
print(x.count('e'))
return 0;
}
# Output: 3
x = 'albert\t1905\tpapers'
If the statement:
print(x.expandtabs())
printf("The ASCII value of ch is: %d", ch);
# Output: albert 1905 papers
209
x = "Alan"
• What will be the output of the following programs? print(x.zfill(4))
# Output: Alan
i) print(x.zfill(6))
# Output: 00Alan
print(x.zfill(8))
#include<stdio.h>
# Output: 0000Alan
int main()
{
int i;
int num [5] ={16,18,19,20,21};
for(i=0;i<5;i++)
printf("\n Element = %d", num[i] +1);
return 0;
}
// program to print the punctuation characters using ASCII value in C
#include <stdio.h>
Answer:
#include <ctype.h>
Element = 17
int main() {
Element = 19
int x;
Element = 20
printf("Punctuation Characters in C: \n");
Element = 21
Element = 22 for(x = 0; x <= 127; ++x) {
if(ispunct(x)!= 0)
printf("%c ", x); }
return 0;
ii)
}
#include<stdio.h> # Output:
int main()
All punctuations in C:
{
int i = 54; ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
int y = i<<1;
printf("The value of y = %d", y);
return 0;
}
Answer:
210
If the statement: i<<1 is replaced by the statement: i<<2
Utility software:
Then the output on the screen is:
The value of y = 216 A kind of system software that assists
Note: • i<<1 implies 54 * 2 = 108 in the configuration, analysis,
reinforcement, maintenance of the
• i<<2 implies 54 * 4 = 216
appropriate and efficient operation of
• i<<3 implies 54 * 6 = 324
a computer system
• i<<4 implies 54 * 8 = 432
VoIP
Answer:
The value of y = 27
If the statement: i>>1 is replaced by the statement: i>>2 An Internet-based phone connection
The value of y = 13
211
• Note: // Import the Scanner class
import java.util.Scanner;
• i>>1 implies 54/2 = 27
public class MyClass {
• i>>2 implies 54/4 = 13 public static void main(String[] args) {
• i>>3 implies 54/6 = 9 // Create a Scanner object
• i>>4 implies 54/8 = 6 Scanner x = new Scanner(System.in);
System.out.println("Enter a string: ");
will be displayed on the console screen because there are only 3 letters in the word "dog".
212
Suppose if you enter the word tech
will be displayed on the console screen because there are only 4 letters in the word tech.
#include<stdio.h>
Python keywords are:
int main()
{ ['False', 'None', 'True', 'and', 'as', 'assert', 'async',
// Output: 54.56
Suppose if you enter the number 4
}
}
Entered number is: 4
213
The factorial of the entered number 4 is: 24
Java Program:
#include <stdio.h>
int main()
public class MyClass {
Answer:
Linux ' linux
Linux ? linux
214
#include<stdio.h>
import java.lang.Math;
#include<stdlib.h>
public class MyClass {
int main () {
public static void main(String[] args) {
printf("linux\n");
int x = 100, y = 70;
exit (0);
printf("php\n"); System.out.println(Math.subtractExact(x, y));
return 0; }
} }
// Output: 30
import java.lang.Math;
Answer:
public class MyClass {
linux
public static void main(String[] args) {
#include<stdio.h>
import java.lang.Math;
int main() {
public class MyClass {
int a, b, c;
public static void main(String[] args) {
a=2;
int x = 100;
b=2;
System.out.println(Math.incrementExact(x));
c = a ^ b;
}
printf( "The value of c = %d", c);
}
}
// Output: 101
Answer:
The value of c = 0
215
Strategy or paradigm for implementing a process of computation
Algorithmic problem solving steps:
Function call
Function definition
Loop
Pattern matching
The action of doing something
A code inside a function that instructs over and over again The process of checking whether
the program on what to do when the a specific sequence of data exists
216
DNS (domain name service) Packets
The service that translates URLs to IP Small pieces of information that have been
addresses. carefully formed from larger pieces of information
Automated Reasoning: Applying reasoning in the form of logic to define, approach and solve problems
Data
Data
Theinformation
The informationthat
thatisissaved
savedon
onaa
computer
computer
To create a file in a 'C' program following syntax is used:
FILE *fp;
fp = fopen ("file_name", "mode");
Function in C programming is a reusable block of code that makes a program easier to understand, test and
can be easily modified without changing the calling program. Functions divide the code and modularize the
program for better and effective results. In short, a larger program is divided into various subprograms which
arecalled as functions.
217
Java Development Kit = Java Runtime Environment + Development tools
Java Runtime Environment = Java Virtual Machine + Libraries to execute the application
Java Program:
218
Java Program: import java.lang.Math;
public class MyClass {
public static void main(String[] args) {
import java.lang.Math;
int x = -16;
public class MyClass {
int y = 35;
public static void main(String[] args) {
System.out.println(Math.negateExact(x));
int x = 100;
// Output: 16
System.out.println(Math.decrementExact(x));
System.out.println(Math.negateExact(y));
}
// Output: -35
}
}
// Output: 99
}
import java.lang.Math;
public class MyClass {
public static void main(String[] args) {
Abstraction
// create long variable
long x = -54965L;
long y = 198876L; A simplified representation of
something more complex
// change long to int
int a = Math.toIntExact(x);
int b = Math.toIntExact(y);
Data centre rationalization
}
}
represented as a 0 or 1
219
Computational thinking: A set of techniques for solving complex problems
Pattern recognition:
Abstraction:
• Focusing on what is important and ignoring what is unnecessary
Python code:
print("{:,}".format(892887872878))
# Output: 892,887,872,878
220
C / C++ categorize statements into:
double x = 8.68;
System.out.println(Math.nextDown(x));
// Output: 8.680000000000001
Input }
}
a=15, b=50, c=55
Here 15 is stored in a, 50 skipped and 55 is stored in the b, since no data is available for c so it
has garbage value. The character * is called the suppression character.
import java.lang.Math;
The infinite loop:
public class MyClass {
double x = 2.693;
printf("This Loop will run forever.\n";)
double y = -3.896;
System.out.println(Math.copySign(x, y));
// Output: -2.693
for( ; ; ) { }
ch = getchar(); Get a character }
if(ch=='B')
221
break; Exit the loop
}
printf("you entered B";)
// This loop will run until the user types a Letter B at the keyword.
C++ Programming
Family C
Developer ISO/IEC JTC1 (Joint Technical Committee 1) / SC22 (Subcommittee 22) / WG21 (Working Group
21)
OS Most major
Filename extensions .C, .cc, .cpp, .cxx, .c++, .h, .hh, .hpp, .hxx, .h++
Bjarne Stroustrup
Creator of C++ language
Website isocpp.org
Major implementations
GCC, LLVM Clang, Microsoft Visual C++, Embarcadero C++Builder, Intel C++ Compiler, IBM XL C++, EDG
Influenced by
222
Ada, ALGOL 68, C, CLU, ML, Mesa, Modula-2, Simula, Smalltalk
Influenced
Ada 95, C#, C99, Chapel, Clojure, D, Java, JS++, Lua, Nim, Perl, PHP, Python, Rust, Seed7
#include <iostream>
#include <string>
using namespace std; Memory address of the
int main() { string "Albert"
string x = "Albert";
cout << &x; // Output: 0x7ffd8e332470
return 0;
}
Advantages: C++ is extremely fast and has the power and extensibility to write large-scale programs and runs on a
variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. Most famous software has their
backbone in C++ and many programming languages depend on C++'s performance and reliability in their
implementation [Examples include: JVM, JavaScript interpreters and Web frameworks]. C++ [a superset of C] is
said to use static typing when type checking is performed during compile-time as opposed to run-time.
Limitation: Some tasks can be implemented in C++, though not very quickly. For example: designing GUI screens
for applications. Other programming languages like VB, Python have GUI design elements built into them.
Therefore, they are better suited for GUI type of task.
Uses: Used in the development of new programming languages [C#, Java, JavaScript, Perl, PHP, Python and
Verilog], Apple Macintosh, PC running Windows, operating systems and Adobe Systems (like Photoshop, Acrobat
etc), softwares for MRI machines, high-end CAD/CAM systems. C++ fully supports most important features of
object-oriented programmingincluding the four pillars of object-oriented development:
223
▪ Encapsulation
▪ Data hiding
▪ Inheritance
▪ Polymorphism
Inheritance: The ability of a class (sub class) to derive properties and characteristics from another class (super
class) is called Inheritance. Inheritance is one of the most important features of Object Oriented Programming.
• Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
• Super Class: The class whose properties are inherited by sub class is called Base Class or Super class.
int main() Main function. Execution of C++ program begins from main()
224
}
and saved with [.cpp] Extension − For example, hello.cpp. File Saved with [.cpp] extension is called Source
Program or Source Code. C++ Source code with [.cpp] Extension is sent to preprocessor first. The preprocessor
generates an expanded source code.
Expanded source code is given as input to compiler where the expanded source program is compiled (i.e., the
program is entirely read and translated to instructions the computer can understand i.e., machine understandable or
readable language i.e., to machine code sequence of 0s and 1s). If the C++ compiler finds any error during
compilation, it provides information about the error to the programmer.
The programmer has to review code and re-edit the program. After re-editing program, Compiler again check for
any error. If program is error-free then it is sent to assembler − where the code is assembled and converted into
object code. Now a simple .obj file is generated.
The object code is sent to linker (where the object code is linked with appropriate libraries). Then it is converted
into a single executable code. A simple .exe file is generated.
The executable code is sent to loader (where the executable code is loaded into memory and then it is executed).
After execution, output:
Hello, world!
225
#include<iostream> → preprocessor statement
This statement begins with # symbol and is also called preprocessor directive. This
statement directs the preprocessor to include a section of standard C++ code
[header iostream] that supports C++ style input output operations [<iostream> is to
C++ what stdio.h is to C, allows to perform standard input and output operations −
such as writing the output of this program "Hello, world!" to the console screen].
There is no .h extension to the name iostream. This is because that <iostream> is
one of the modern style headers defined by standard C++.
• i → input
• o → output
• stream → screen
and it is included into the C++ program by writing the statement #include<iostream>.
The statement #include tell the compiler to include the contents of the file iostream
before compilation.
If a program is written without the statement: #include<iostream> then the C++ compiler can't compile and a
compilation error is displayed on the screen (because C++ compiler fails to recognize the functions such as cin and cout).
The function named main is a special function in all C++ programs; it is the
function called when the C++ program is executed. As the name itself indicates
this is the main function of every C++ Program. Parentheses " () " indicate a
function and the word main indicate the name of the function.
226
main()implies: main function. Execution of C++ program begins from main(). No C++ program is executed without
main(). It is case sensitive language: only lower case letters (or small letters) must be used and should not be enclosed by a
semicolon. There must be one and only one main()function in every C++ program.
• main()
Classes and objects are
• int main()
supported by C++ but not by C
• void main()
• main(void)
• void main(void)
• int main(void)
As we know C++ is Platform dependent language. So the Operating system needs to know when the program
execution ends. So when there is value returns from the main function, the Operating System get to know that
the program execution is over. int main() implies: main()should return integer value.
▪ If the main function returns 0 to the operating system, then the program has completedexecution successfully.
▪ If the main function returns 1 to the operating system, then the program has notcompleted execution
successfully.
int main() {
Body of the main function within which the sequence of instructions to the computer to
perform specific operations in the form of statements [input-output statements, arithmetic
}
statements, control statements and other statements] are written and executed
#include <iostream>
string x = "Hi Alan"; #include <cstring>
using namespace std;
'H' 'i' ' ' 'A' 'l' 'a' 'n' string x = "Hi Alan";
cout << x.length();
return 0;
Length: 7
}
// Output: 7
227
The left curly brace
{
implies: the beginning of the main function and the right curly brace
}
These braces can also be used to indicate the beginning and end of user-defined functions and
compound statements.
return 0; → implies the exit status of execution of the program i.e., at this point, main
function returns back the control of the computer to the operating system since the execution is
terminated at this point and once a return statement i.e., return 0; is executed, no further
instructions within the main function are executed.
For example:
; → implies semicolon or statement terminator [a delimiter of the declaration] → All C++ statements must
end with a semicolon character. One of the most common syntax errors in C++ is forgetting to end a statement
with a semicolon. A program is a well-defined set of instructions and each well-defined instruction (in the form
of a statement) is ended by a semicolon (which is C++ language punctuation − like a period in English i.e., in
an English paragraph eachsentence is ended by a full stop which tells that one sentence ends and another begins,
semicolon implies the end of one logical entity − that one instruction (or statement) ends and another begins).
228
// My First C++ Program → Comment
A good programmer who writes codes understood by a human is better than a programmer who generates codes
understood only by the machine. So, it is highly recommended to insert comments. Comment is explanatory note on
some instruction. Two slash signs indicate that the rest of the line is a comment inserted by the programmer but
which has no effect on the behavior of the C++ program. Comment statement is not compiled and executed.
• "\n" is used in both C and C++ but "\n" occupies 1 byte memory
• endl is used in C++ but not in C
• endl doesn't occupy any memory
// Output: // Output:
Alan Alan
Albert Albert
cout→ implies the standard way of displaying output on the screen and output
function of the C++ language which makes provision to print the output:
229
First, std::cout which a l l o w s u s t o s e n d d a t a t o t h e c o n s o l e s c r e e n t o b e
p r i n t e d a s t e x t . std::cout i s d e f i n e d i n t h e i o s t r e a m h e a d e r f i l e .
▪ std → standard
▪ :: → scope resolution operator
▪ cout → console output or character output
std::cout basically means: look in standard library and get cout function.
Hello, world!
If the statement:
using std::cout;
230
#include<iostream>
C Program:
01
012
i.e., no need to include std:: in the statement: 0123
C++ Keywords:
231
continue default do
for goto if
signed sizeof static
void volatile while
reinterpret_cast bool
false catch
private class
throw const_cast
true try
virtual wchar_t
C Program:
int main()
#include<stdio.h>
{
enum names{Albert, Alan, John, David, Turing, Weinberg, Friedrich};
int i, j;
int main()
i=10;
{
j=i*2;
enum names scientist;
return j;
scientist = John;
} → NO ERROR
printf("%d", scientist);
Output:
return 0;
int main()
2
}
{
int i;
i=10;
232
int j;
j=i*2;
return j;
} → ERROR
Type Keyword
Boolean bool
Character char
Integer int
Valueless void
#include <iostream>
using namespace std;
int main() {
cout << "Size of char: " << sizeof(char) << endl;
cout << "Size of int: " << sizeof(int) << endl;
cout << "Size of short int: " << sizeof(short int) << endl;
cout << "Size of long int: " << sizeof(long int) << endl;
cout << "Size of float: " << sizeof(float) << endl;
cout << "Size of double: " << sizeof(double) << endl;
cout << "Size of wchar_t: " << sizeof(wchar_t) << endl;
return 0;
}
233
#include <iostream>
Size of char: 1
using namespace std;
Size of int: 4
Size of short int: 2 int main() {
*****
*****
*****
*****
234
on screen #include <iostream>
using namespace std;
template <typename T>
#include<iostream>
using std::cout;
int mult (T x,T y) {
int main()
return (x*y);
{
}
cout<<"\n * ";
int main() {
cout<<"\n ***** ";
cout<<mult<int>(2,4);
cout<<"\n ***** ";
return 0;
cout<<"\n ***** ";
}
cout<<"\n ***** "; Output:
return 0;
} 8
*
*****
*****
*****
*****
If new line \n is not included in the above program then the output on the screen is:
235
cout<<" ***** "<< endl;
cout<<" ***** "<< endl;
return 0;
}
#include<iostream>
Output:
using std::cout; #include <bits/stdc++.h>
using std::endl; using namespace std;
11
int main() int main(){
12
{ vector<int> num{
cout<<" * "<< endl; 11,19,14,13,12,18,15,17}; 13
cout<<" ***** "<< endl; sort(num.begin(), num.end()); 14
cout<<" ***** "<< endl; for (auto a : num) 15
cout<<" ***** "<< endl; cout << a << "" ""<< endl;
17
cout<<" ***** "<< endl; return 0;
18
return 0; }
} 19
#include<iostream>
The output on the screen: using namespace std;
*
int main() {
*****
int x= 20, y= 50;
*****
bool z, p;
*****
z= (x == y);
*****
p= (x < y);
cout << z <<endl;
cout << p << endl;
return 0;
The single statement: Output:
} 0
1
236
using namespace std;
using std::cout;
using std::endl; #include<iostream>
#include<vector>
using namespace std;
237
Stream Meaning Default device
cin Standard input Keyboard
cout Standard output Screen
cerr Standard error output Screen
clog Buffered version of cerr Screen
C Program:
#include <stdio.h>
int main() { Output:
if(printf("Albert Einstein")) {
Albert Einstein
}
return 0;
}
#include <stdio.h>
int main() {
#include <stdio.h>
void abc(void) { int a=2;
void abx(void); if(a==0)
printf("\n Albert Einstein"); return;
abx(); printf("Value is not equal to Zero.");
}
}
int main() {
abc();
Output:
return 0;
} Value is not equal to Zero.
void abx(void) {
printf("\n Alan Turing");
}
Resource starvation
Output:
A situation in which a process does not receive the
Albert Einstein resources it requires to finish a task due to resource
Alan Turing allocation to other processes
238
Java Program:
public class HelloWorld {
} }
} }
Output:
Output:
Alan Turing
Lieserl Einstein
Albert Einstein
import java.util.ArrayList;
import java.util.Collections;
Output:
239
public class HelloWorld {
public static void main(String[] args) {
Output:
System.out.println(1900 + 05 + "Papers"); 1905Papers
System.out.println("Office" + 36 + 05);
} Office365
}
#include <iostream>
int main () {
int n = -77;
return 0;
}
Java Program:
-77
Output:
1905Papers
Office365
(a)
240
****
#include <iostream>
*******
using namespace std;
Output:
C program:
241
Python code:
#include<iostream>
using namespace std; string = "Albert"
int main() list = ["Computer", "Mouse", "Keyboard", "Camera", "Disk"]
{ tuple = ("Car", "Flight", "Ship")
cout<<"\n * "; dictionary = {
cout<<"\n **** "; "Albert": "Einstein",
cout<<"\n ******* "; "John": "Turing",
cout<<"\n **** "; "David": "Hilbert",
cout<<"\n * "; "Alan": "Mary",
return 0; }
}
print("The minimum value of string is: ", min(string))
print("The minimum value of list is: ", min(list))
print("The minimum value of tuple is: ", min(tuple))
(b) print("The minimum value of dictionary is: ", min(dictionary))
Output:
Output:
(c)
11
242
def myfunc(x, y):
#include<iostream> print (x/y)
A modern-style C++ program that uses the new style headers and a namespace:
#include<iostream>
Using namespace std; Integer overflow
int main()
A kind of an arithmetic overflow error
{
return 0; results when an arithmetic operation
} outputs a numeric value that goes
outside allocated memory space or
// It includes C++ style header and specifies a namespace.
overflows the range of the specified
integer value
243
C Program:
#include <stdio.h>
int main() {
Output:
int i;
for(i=97; i<=122; i++) abcdefghijklmnopqrstuvwxyz
{
printf("%c ", (char)i);
}
return 0;
}
Program 1.3
#include<iostream>
using namespace std; Informed Search Uninformed Search
main()
AI receives AI does not receives
{
recommendations on recommendations on
int r, area;
r = 2; how and where to find how and where to find
area = 3.14 * r * r; a solution to any issue a solution to any issue
cout<<"The area of the circle = "<< area;
return 0;
}
Duplex transmission
If the statement:
float r, area;
At the same time, data is transmitted
in both directions
is used instead of
int r, area;
244
Python code:
i.e.,
import pandas as pd
#include<iostream>
x={"col1":[1,2,3],"col2":['Albert','Mary','Alan']}
using namespace std; y=pd.DataFrame(x)
x={"col1":[4,5,6],"col2":['John','Hilbert','David']}
int main()
z=pd.DataFrame(x)
{
a=pd.concat([y,z],axis=0)
float r, area;
print(a)
r = 2;
col1 col2
area = 3.14 * r * r;
0 1 Albert
cout<<"The area of the circle = "<< area;
return 0;
1 2 Mary
} 2 3 Alan
0 4 John
If you want to supply the value for r through the key board, then the statement
float r = 2;
import pandas as pd
x={"col1":[1,2,3],"col2":['Albert','Mary','Alan']}
y=pd.DataFrame(x)
should be replaced by the statements x={"col1":[4,5,6],"col2":['John','Hilbert','David']}
z=pd.DataFrame(x)
cout<<"Enter any number:";
a=pd.concat([y,z],axis=1)
cin>>r;
print(a)
i.e., Output:
245
cin>>r; x={"b1":11,"b2":12,"b3":13}
area = 3.14 * r * r; for a in x.keys():
cout<<"The area of the circle = "<< area; x[a]=x[a]+1
return 0; print(x[a])
}
# Output:
12
13
The output on the screen: 14
on the screen.
# Output:
0
1
• cin>> r; is to C++ what scanf("%d", &r); is to C
for x in range(5):
0
if x==2: continue
1
print(x)
If you write the statement: 3
area = 3.14 * r ^ 2; 4
246
instead of
area = 3.14 * r * r;
Then compilation error will be displayed on the console screen because like in C Language –
there is no operator for performing exponentiation operation − so the statement
▪ cout and cin are not part of C++ language but they are part of iostream
file. Hence the statement #include<iostream> should be included in the
C++ program otherwise cout and cin will not work and the compilation
error will be displayed on the console screen.
▪ Right shift operator >> denote stream extraction operator (extract data
entered through the keyboard).
▪ Left shift operator << denote stream insertion operator (insert data
into an output screen)
▪ << and >> are termed overloaded operators and the file iostream defines
these operators.
As told earlier: when you enter an integer for x through the keyboard, this integer will be stored
in the computer memory. If you yearn to know the storage size of the integer in computer
memory (i.e., space occupied by the entered integer in the computer memory), you need to
appeal to the following program:
#include<iostream>
using namespace std;
247
int main()
{
# returns the hash value of x
int x;
x=hash(6.7)
x=10;
print(x)
cout<<"size of r = "<< sizeof(r);
return 0;
names=['Albert','Alan','John','Mary','David']
}
x=' '.join(names)
print(x)
size of x = 4
i.e., integer entered for r i.e., 10 has occupied a space of 4 bytes in the computer memory.
• const: Objects of type const cannot be changed by your program during execution.
• volatile: The modifier volatile tells the compiler that a variable's value may be changed in ways not
• restrict: A pointer qualified by restrict is initially the only means by which the object it points to can be
x=6.5%1.2 x={1,3,4,4}=={1,3,4}
Answer: print(x) print(x)
# Output: 0.5000000000000002 # Output: True
#include<iostream>
using namespace std;
x=2.2+3.3>5.5
int main() x=3^2
print(x)
{ print(x)
# Output: False
float r, area; # Output: 1
r = 2.5;
248
circumference = 2* 3.14 * r;
cout<<"The circumference of the circle = "<< circumference;
return 0;
}
• Write a program to print the area of the rectangle (given l = 2.5 and b = 3)
x={11:11,12:14,13:19,14:18,15:28}
Answer: print(type(x))
# Output: <class 'dict'>
#include<iostream>
using namespace std; def myfunc():
int main() """ Albert """ Output:
{ print("Einstein")
float l, b, area; myfunc() Einstein
l = 2.5;
b = 3;
area = 1*b;
cout<<"The area of the rectangle = "<< area;
return 0;
}
• Program 4.6
print('z' in {'x':11,'y':12,'z':13}.values())
#include<iostream> print(13 in {'x':11,'y':12,'z':13}.values())
using namespace std;
int main() # Output:
{ False
int a, b, sum; True
a=1;
b=2;
sum = a + b;
cout<<"the sum of a and b = "<< sum;
return 0;
249
}
If you assign the floating point values 1.5 and 2.6 for a and b, then the statement:
int a, b, sum;
float a, b, sum;
print('albERt'.swapcase())
i.e., # Output: ALBerT
print(bytes([12,14,18]))
#include<iostream>
using namespace std; # Output: b'\x0c\x0e\x12'
int main()
{
float a, b, sum;
a=1.5;
b=2.6; # Infinite loop in python
sum = a + b;
cout<<"the sum of a and b = "<< sum; def myfunc(x):
return 0; while(x==7):print(x)
x="a"
y=5
The statement: print(x + "{0:.3f}".format(y))
250
x="a"
make provision to print the output:
y=5
the sum of a and b = 4.1 print("x={0} but y={1}".format(x,y))
is omitted from the C ++ program, then the program will be successfully executed but there will
be no display of the output on the console screen.
If you want to supply the values for a and b through the key board, then the statements:
a=1.5;
b=2.6;
x ="John"
print (x * 2)
# Output: JohnTuring
i.e.,
251
x = (1927, 'George')
cin>>b;
sum = a+ b; print (x * 2)
cout<<"the sum of a and b = "<< sum;
return 0; # Output: (1927, 'George', 1927, 'George')
}
# Output: 18.16590212458495
The statement:
cin>>a;
cin>>b;
make provision to read the two numbers 2.9 and 3.6 entered through the keyboard and store
them in the computer memory.
def main():
print('Albert Einstein')
Albert Einstein
252
x=15
are replaced by the statements: if x ==15:
print("Albert")
else:
cout<<"Enter any number:"; pass
cin>>a;
cout<<"Enter any number:"; # Output: Albert
cin>>b;
import json
x = json.dumps([11, 62,33, "albert", "beer"])
print(x)
Then the output on the screen is:
Output:
def X(i):
Then the output: def Y():
print(i)
2.9 + 3.6 = 6.5
return Y
253
• What will be the output of the following program:
print(6.0 <= 6)
#include<iostream>
using namespace std;
# Output: True
int a = 5;
int main()
import numpy
{
print(numpy.array([]))
int a =2;
print(numpy.empty(shape=(0,0)))
cout<< a;
return 0;
} # Output:
[]
[]
Answer:
The statement:
int a = 2;
int a = 5; # Output:
A
imply: global variable declaration.
l
b
e
If the statement: r
t
254
cout<< a;
def myfunc(n):
i.e.,
x=1
while(x<=n):
#include<iostream>
yield x**3
using namespace std;
int a = 5; x+=1
int main() for x in myfunc(3):
{ print(x) Output:
int a =2; 1
cout<< ::a;
8
return 0;
}
27
5 x = [[11,12]] * 5
print(x)
i.e., global variable will be outputted on the screen.
# Output:
[[11, 12], [11, 12], [11, 12], [11, 12], [11, 12]]
If the same program is written in C language
x = [[11,12] for _ in range(3)]
i.e., print(x)
#include<stdio.h>
# Output:
int a = 5;
[[11, 12], [11, 12], [11, 12]]
int main()
{
int a =2;
print("%d", ::a);
255
return 0;
}
Then the compilation error will be outputted on the screen because scope
resolution operator is not defined in the C language (i.e., C does not hold
scope resolution operator).
x = open('1.txt')
for i in x:
i = i.strip('\n')
print(i)
Output:
Albert Einstein was a theoretical physicist who was born in Germany and is largely
regarded as one of the greatest and most influential physicists of all time.
Content of 1.txt
x = [[11,12,13,14]]
x[0][3] = 59
#include<iostream>
print(x)
using namespace std;
int main()
# Output: [[11, 12, 13, 59]]
{
int a, b, c;
x = []
a=3;
for i in range(4):
b=2;
x.append(lambda: i)
c= a+b;
print ([y() for y in x])
cout<<" sum of two numbers = 6"<< c;
return 0;
# Output: [3, 3, 3, 3]
}
256
Answer:
Executable
Yes, the output on the screen is:
The binary file that is
sum of two numbers = 65
formed when the source
code is built
• Program 4.7
x = []
for i in range(4):
#include<iostream> x.append(lambda i = i : i)
using namespace std; print ([y() for y in x])
int main()
{
# Output: [0, 1, 2, 3]
float C, F;
C=38.5;
F = 9*C/5 +32;
cout<<"temperature in Fahrenheit= "<< F; print([ [ ] ] * 3)
return 0;
} # Output: [[], [], []]
If you want to supply a value 16 digits after decimal point i.e., 36.5555555555555555 for C,
then the statement:
double C, F;
257
should be used instead of the statement:
float C, F;
x = ['a', 'l', 'a', 'n']
print (x[2:])
i.e.,
print (x[7:])
#include<iostream>
using namespace std;
# Output:
int main()
['a', 'n']
{
[]
double C, F;
C=38.5555555555555555;
F = 9*C/5 +32;
cout<<"temperature in Fahrenheit= "<< F;
return 0;
}
If you want to supply the value for C through the key board, then the statement:
C=38.5;
258
}
import array
import array
x = open('1.txt') x = array.array('i', [50,25,15])
y = x.readlines() x.insert(3, 5)
type(y) print(x)
print(y)
# Output: array('i', [50, 25, 15, 5])
Output:
['Albert Einstein was a theoretical physicist who was born in Germany and is largely
regarded as one of the greatest and most influential physicists of all time.']
259
{
int a, b, product; import array as myarray
a=1; x = myarray.array('i', [12,22, 32])
b=2; x.reverse()
product = a * b; print(x)
cout<<"the product of a and b = "<< product;
return 0; # Output: array('i', [32, 22, 12])
}
x = "Albert Einstein"
y = "Alan Turing"
If you want to insert a 10 digit number for a and b i.e.,
print (x[1])
print (y[1:4])
a=1000000000
b=3000000000 # Output:
l
lan
int a, b, product;
i.e.,
import numpy as np
x = np.array([[15, -50, 33], [51, -56, 65], [-42, 79, 82]])
#include<iostream>
print(x)
using namespace std;
int main()
[[ 15 -50 33]
{
[ 51 -56 65]
long int a, b, product;
a=1; [-42 79 82]]
b=2;
260
product = a * b;
cout<<"the product of a and b = "<< product; Package declaration
return 0;
}
A declaration that is used
to identify a package
If you want to supply the integer values for a and b through the key board, then the statements:
a=1;
import numpy as np
x = np.array([[13, 16, 19], [15, -20, 25], [-17, 24, 56]])
b=2; should be replaced by the statements:
y = np.array([[91, -15, 87], [10, 28, 53], [63, -18, 38]])
z = x - y
cout<<"Enter any two numbers:"; print(z)
cin >> a;
cin >> b; [[-78 31 -68]
[ 5 -48 -28]
[-80 42 18]]
i.e.,
#include<iostream>
using namespace std; import numpy as np
int main () x = np.array([[13, 16, 19], [15, -20, 25], [-17, 24, 56]])
{ y = np.array([[91, -15, 87], [10, 28, 53], [63, -18, 38]])
int a, b, product; z = x.dot(y)
cout<<"Enter any two numbers:"; print(z)
cin>>a;
[[ 2540 -89 2701]
cin>>b;
product = a* b; [ 2740 -1235 1195]
cout<<"the product of a and b = "<< product; [ 2221 -81 1921]]
return 0;
}
261
The output on the screen:
x = [12,13,14,13,20,13,15,16,13]
Enter any two numbers: y = x.count(13)
print(y)
If you enter two numbers 2 & 3
Output:
the product of a and b = 6
4
will be outputted on the screen
• Numbers
• Operators +, −, /, *,^,%, =
• Parentheses
• Variables
• Program 4.9
262
The output on the screen:
the square of a = 4
If you want to supply the integer value for a through the key board, then the statement:
a=2;
import math
should be replaced by the statements:
print(math.pi)
i.e., Output:
3.141592653589793
#include<iostream>
15
using namespace std;
int main()
{
int a, b;
cout<<"Enter any number:";
cin>>a; x = ['Car', 'House', 'Phone', 'Computer']
b = a * a; print(x[-1][-1])
cout<<"the square of a = "<< b;
return 0; # Output: r
}
the square of a = 9
will be outputted on the screen.
263
• Write a program to print the cube of a number
Answer:
#include<iostream>
using namespace std;
y = {'age': 102, 'name': 'Mary', 'Car': 'Audi'}
int main()
x = y.setdefault('name')
{
int m, a, F; print(x)
cout<<"Enter the mass:";
cin>>m; # Output: Mary
cout<<"Enter acceleration:";
cin>>a;
F = m * a;
cout<<"the force applied to the mass = "<< F;
return 0;
}
Output: Albert Einstein had a net worth equal to $65.00000 thousand at the time of his death in 1955.
264
x = open('1.txt')
y = x.readline()
Output:
while y!= "":
print(y) Albert Einstein was a theoretical physicist who was born in Germany and is
y = x.readline()
largely regarded as one of the greatest and most influential physicists of all time.
Output:
• Program 5.0
} # Output: 27456
# 16 × 12 × 13 × 11 = 27456
else
265
}
#include<iostream>
using namespace std;
int main() y = [22, 26, 66, 46, 46, 70, 46, 52]
{ x = []
int a, b;
[x.append(i) for i in y if i not in x]
a = 2; print (x)
b = 3;
if(a>b)
{
Output:
cout<<"a is greater than b";
} [22, 26, 66, 46, 70, 52]
else
{
cout<<"b is greater than a";
}
return 0;
}
b is greater than a
• Program 5.1
C++ program to find the greatest of three numbers using else-if statement
{ print(x)
266
{
{
# Output: [24, 28, 20, 16]
print this statement;
{
int a, b, c; Output:
cout<<"Enter any number:";
cin>>a; [16, 15, 14, 13, 12, 11]
cout<<"Enter any number:";
cin>>b;
cout<<"Enter any number:";
cin>>c;
if(a>b&&a>c)
{
cout<< a<<" is greater than"<< b<<" and "<<c;
}
else if (b>a&&b>c)
{
cout<< b<<" is greater than"<< a <<" and "<<c;
}
else
{
cout<< c<<" is greater than"<< b<<" and "<< a;
}
267
The output on the screen:
#include <iostream>
using namespace std;
int main()
{
int a, b; x = ["Haw", "w", "a", "physi"]
a=2; y= ["king", "as", "n", "cist"]
b=2;
z = [(a, b) for a in x for b in y]
if(a>b || a==b)
c = [a + ' ' + b for (a, b) in z]
cout<<"a is greater than or equal to b";
print(c)
else
cout<<"b is greater than a";
return 0;
Output:
}
['Haw king', 'Haw as', 'Haw n', 'Haw cist', 'w king', 'w as', 'w n', 'w cist', 'a king',
'a as', 'a n', 'a cist', 'physi king', 'physi as', 'physi n', 'physi cist']
Answer:
268
• Program 5.2
#include<iostream>
using namespace std;
int main()
{
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, X;
cout<<"Enter any 10 numbers:";
cin>>N1;
cin>>N2; x = [-15, 57, 500, -41, -20, -810, 266, -97]
269
For example:
• Program 5.3
x, y = 12, 20
print(x if x < y else y)
#include<iostream>
# Output: 12
#include<cmath>
using namespace std;
x=12
int main()
{ x,y=x+1,x+2
int a, b; print(x,y)
cout<<"Enter any number:";
cin>> a; # Output: 13 14
b = sqrt (a);
cout<<"the square root of a number = "<< b;
return 0;
}
270
the statement: #include<cmath> must be included in the above program because
cmath file defines the mathematical functions like sqrt().
def upto(x):
#include<iostream>
for a in range(x-1):
using namespace std;
yield a
int main()
{ for i in upto(5):
int a, b; print(i)
cout<<"Enter any number:";
Output:
cin>> a;
0
b = sqrt (a);
1
cout<<"the square root of a number = "<< b;
return 0; 2
} 3
x = {11:12, 13:14}
y = {13:15, 15:16}
Answer: z = {**x, **y}
print(z)
#include<iostream>
#include<cmath> # Output: {11: 12, 13: 15, 15: 16}
271
using namespace std;
int main()
{
cout<<"the cube root of a number = "<< cbrt (8);
return 0;
}
• Program 5.4
x = []
#include<iostream> y = []
using namespace std; z = x
int main() print(x == y) Output:
{ print(x is y)
int P,T, R, SI; True
print(x is z)
P = 1000;
False
T = 2;
True
R = 3;
SI = P*T*R/100;
cout<<"the simple interest = "<< SI;
return 0;
}
If you want to supply the integer values for P, T and R through the key board, then the
statements:
P = 1000;
272
T = 2;
R = 3;
273
If you enter the principal amount 1000 try:
#include<iostream>
from itertools import permutations
using namespace std;
int main()
x = [11, 12, 13]
{ y = permutations(x)
int age; print(list(y))
age=20;
if(age > = 60)
{
cout<<"senior citizen";
}
[(11, 12, 13), (11, 13, 12), (12, 11, 13), (12, 13, 11), (13, 11, 12), (13, 12, 11)]
if(age<60)
{
cout<<"not a senior citizen"; x = {"John": 42, "Joseph": 20, "James": 10}
} print("James" in x)
return 0;
}
# Output: True
274
If you want to supply the value for age through the key board, then the statement:
age = 20;
275
will be outputted on the screen.
Default constructor
Information hiding
will be outputted on the screen. The idea that development decisions should be
concealed by the modules in which they are used
• Program 5.6
If the marks >= 35 in all the subjects the student passes else fails.
Python code:
#include<iostream>
using namespace std; import array as arr
{ print (x[::-1])
else shuffle(a)
{ print(a)
cout<<"candidate is failed";
} Output:
return 0;
[' theoretical', 'Einstein', 'is', 'a', 'Albert', 'physicist']
}
276
The output on the screen:
candidate is passed
If you want to supply the integer values for marks M1, M2 and M3 through the key board, then
the statements:
x='ALBERT'
print(x.lower())
M1 = 38; # Output: albert
M2= 45;
M3 = 67; x='ALBERT'
print(len(x))
# Output: 4
*
# Output:
i.e., ***
*****
#include<iostream> *******
using namespace std; *********
***********
int main()
x = 13
{
if x > 1:
int M1, M2, M3;
for a in range(2, int(x/2)+1):
cout<<"Enter any three marks:";
if (x % a) == 0:
cin>> M1;
print(x, "is not a prime number")
cin>> M2;
break
cin>> M3;
else:
if(M1 >= 35 && M2>= 35 && M3>= 35)
print(x, "is a prime number")
{
else:
cout<<"candidate is passed";
print(x, "is not a prime number")
}
else
# Output: 13 is a prime number
{
277
x='535'
cout<<"candidate is failed"; y=x[::-1]
} if x==y:
return 0; print("palindrome")
} else:
print("Not a Palindrome")
# Output: palindrome
The output on the screen:
x = ["12", "42", "50", "16", "19"]
Enter any three marks:
x = [int(a) for a in x]
26, 28, 39 # entered marks x.sort()
candidate is failed print (x)
x = dict(zip(('a','b','c','d','e'),(11,12,13,14,15)))
print(x)
Program 5.7 # Output: {'a': 11, 'b': 12, 'c': 13, 'd': 14, 'e': 15}
278
x = True + 5
}
y = False + 8
print(x)
print(y)
# Output:
[6, 11, 8, 2, 10, 6]
[11, 8, 2, 10, 6]
• Program 5.8
x = [ 3, 11, 8, 2, 10, 3 ]
print(x)
#include<iostream>
del x[3]
using namespace std;
print(x)
int main()
{
# Output:
float I, C;
[3, 11, 8, 2, 10, 3]
I=3.5;
[3, 11, 8, 10, 3]
C = 2.54*I;
cout<<"length in centimeters = "<< C;
x = "lber"
return 0;
y = "At"
}
print(x.join(y))
# Output: Albert
import urllib.request
urllib.request.urlretrieve("https://parade.com/wp-content/uploads/2021/08/albert-einstein-quotes.jpg", "img1.jpg")
279
▪ Note: float is used instead of int because I = 3.5 if int is used
instead of float then the result will not be clearly outputted i.e.,
instead of 8.89 the computer displays only 8.
If you want to supply the value for I through the key board, then the above program should take
the form:
x = 10
y = 14
z = x if x < y else y
#include<iostream>
print(z)
using namespace std;
int main()
# Output: 10
{
float I, C;
x, y = 15, 15
cout<<"Enter the length in inches:";
print(x==y)
cin >> I;
print(x<y)
C = 2.54*I;
print(x<=y)
cout<<"length in centimeters= "<< C;
print(x!=y)
return 0;
}
# Output:
True
False
The output on the screen:
True
Enter the length in inches: False
• Program 5.9
C++ program to find the incremented and decremented values of two numbers
Constructor
#include<iostream>
using namespace std; A class function that creates new objects
int main()
within the class
280
x=13
{
print(x)
int a, b, c, d, e, f;
Output:
x += 3
a = 10;
print(x) 13
b=12;
x -= 3
c=a+1; 16
print(x)
d=b+1; 13
x *= 3
e=a-1; 39
print(x)
f=b-1;
x **=3 59319
cout<<"the incremented value of a = "<< c;
print(x)
cout<<"the incremented value of b = "<< d;
cout<<"the decremented value of a = "<< e;
cout<<"the decremented value of b = "<< f;
x = True
return 0;
y = False
}
print(x and y)
# Output: False
If the statements:
x = True
cout<<"the incremented value of a = "<< c; y = False
cout<<"the incremented value of b = "<< d; print(x or y)
cout<<"the decremented value of a = "<< e;
cout<<"the decremented value of b = "<< f; # Output: True
x = True
y = False
are replaced by the statements: print(not y)
281
Then the output on the screen is:
x = [22,24,26,27,33,34]
# Output: False
x = 50
are replaced by the statements: y = 24
print(x is not y)
If you want to supply the values for a and b through the key board, then the above program
should take the form:
#include<iostream>
282
using namespace std; Data sink
int main()
{
A storage device that collects and stores data for an
int a, b, c, d, e, f; unlimited amount of time
cout<<"Enter any number:";
cin>> a;
cout<<"Enter any number:"; x = ("\u0123", "\u2665", "\U0001f638", "\u265E", "\u265F", "\u2168")
c=a+1;
d=b+1; # Output: ('ģ', '♥', '😸', '♞', '♟', 'Ⅸ')
e=a-1;
f=b-1;
cout<<"\n the incremented value of a = "<< c;
cout<<"\n the incremented value of b = "<< d;
cout<<"\n the decremented value of a = "<< e;
cout<<"\n the decremented value of b = "<< f;
return 0;
}
x= "Albert Einstein profoundly changed physics"
print(x[3:15])
283
#include<iostream> import array as arr
using namespace std; x = [2, 'pqr', 2.55]
int main() print (x)
{
float T1, T2, A; # Output: [2, 'pqr', 2.55]
cout<<"Enter any number:";
cin >>T1;
cout<<"Enter any number:";
cin >>T2;
A = (T1 + T2) / 2;
cout<<"the average temperature of the day = "<< A;
return 0;
}
import os
os.remove('hello.txt')
• Program 6.0
The percentage marks are entered and the grades are allotted as follows:
284
Mutator
Write a C++ program for the above:
A function that modifies the
state of an object
#include<iostream>
using namespace std;
main()
{
import array as arr
int P;
x=arr.array('b',[11, 12, 13, 14, 15])
cout<<"Enter the percentage:";
print(x[::-1])
cin>>P;
if(P >= 60)
import array
{
x = array.array('b', [11, 12, 13, 14, 15])
cout<<"first class";
print(x[::-1])
}
if(P>=50&&P <60)
{
from array import *
cout<<"second class";
x =array('b',[11, 12, 13, 14, 15])
}
print(x[::-1])
if(P>=40&&P<=50 )
{
cout<<"pass class";
} Output:
if(P<40)
{ array('b', [15, 14, 13, 12, 11])
cout<<"fail";
}
return 0;
def myfunc():
}
return 14, 15, 16, 17
a, b, c, d = myfunc()
print(a, b, c, d)
285
• Program 6.1
C++ program to calculate the discounted price and the total price after discount
Given:
# Output: 28
#include<iostream>
using namespace std;
x = [11, 12, 13, 19, 12, 17, 13, 15, 19, 19, 19]
int main()
print(max(set(x), key = x.count))
{
double PV, dis;
# Output: 19
cout<<"Enter purchased value:";
cin>>PV;
from collections import Counter
if(PV>1000)
def myfunc(a, b):
{
return Counter(a) == Counter(b)
cout<<"dis= "<< PV* 0.1;
print(myfunc('Alan', 'Albert'))
}
print(myfunc('Alan', 'Alan'))
else if(PV>5000)
{
cout<<"dis= "<< PV* 0.2;
Output:
}
False
else
True
{
cout<<"dis= "<< PV* 0.3;
}
return 0;
}
286
The output on the screen: Accessor
287
total = 585.000000
will be outputted on the screen.
import pandas as pd
names=["Alan","John","Albert","Joseph","Mary"]
#include<iostream> jobs=["Chemist","Biologist","Physicist","Engineer","Teacher"]
using namespace std; y={"jobs":jobs,"names":names}
int main() x=pd.DataFrame(y)
{ q=[1,2,3,4,5]
double PV, dis, total; x.index=q
cout<<"Enter purchased value:"; print(x.loc[4])
cin>>PV;
if(PV>1000)
{ Output:
cout<<"dis= "<< PV* 0.1;
jobs Engineer
cout<<"total= "<< PV - PV* 0.1;
} names Joseph
else if(PV>5000) Name: 4, dtype: object
{
cout<<"dis = "<< PV* 0.2;
cout<<"total= "<< PV - PV* 0.2; import pandas as pd
} x=[11,12,13]
else y=[21,31,51]
{ a={"num1":x,"num2":y}
cout<<"dis= "<< PV* 0.3; z=pd.DataFrame(a)
cout<<"total= "<< PV - PV* 0.3; z["Sum"]=z["num1"]+z["num2"]
} z["Difference"]=z["num1"]-z["num2"]
return 0; print(z)
}
Output:
288
import pandas as pd
If you enter the purchased value 850 x={"col1":[1,2,3],"col2":["John","Alan","Mary"]}
y=pd.DataFrame(x)
dis = 85.000000
print(y)
col1 col2
total = 765.000000
0 1 John
will be outputted on the screen. 1 2 Alan
2 3 Mary
• Program 6.2
C++ program to print the first ten natural numbers using for loop statement
import pandas as pd
x={"col1":[1,2,3],"col2":["John","Alan","Mary"]}
#include<iostream> y=pd.DataFrame(x)
using namespace std; y=y.drop(["col1"],axis=1)
int main() print(y)
{ col2
int i;
0 John
for (i=1; i<=10; i++)
1 Alan
cout<<"value of i = "<< i;
return 0;
2 Mary
}
for x in range(4):
for a in range(x): 1
print(x, end=" ")
• When for loop executes, the following occurs: print("\n") 22
333
i = 1
Is the condition (i<=10) is true?
Yes because i=1
The statement cout<<"value of i = "<< i; is executed to print the output:
289
Data corruption
value of i = 1
Now, the value of i is:
A breach of data security
i = 1+1 = 2
Is the condition (i<=10) is true?
Yes because i=2
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 2
Now, the value of i is:
i = 2+1 = 3
Is the condition (i<=10) is true?
Yes because i=3
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 3
Now, the value of i is:
i = 3+1 = 4
Is the condition (i<=10) is true?
Yes because i=4
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 4
Now, the value of i is:
i = 4+1 = 5
Is the condition (i<=10) is true?
Yes because i=5
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 5
Now, the value of i is:
i = 5+1 = 6
Is the condition (i<=10) is true?
Yes because i=6
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 6
Now, the value of i is:
i = 6+1 = 7
Is the condition (i<=10) is true?
Yes because i=7
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 7
Now, the value of i is:
Concept phase:
i = 7+1 = 8
Is the condition (i<=10) is true? The first phase of a software development process during
Yes because i=8 which user requirements are documented and reviewed
290
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 8
Now, the value of i is:
i = 8+1 = 9
Is the condition (i<=10) is true?
Yes because i=9
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 9
Now, the value of i is:
i = 9+1 = 10
Is the condition (i<=10) is true?
Yes because i=10
The statement cout<<"value of i = "<< i; is executed to print the output:
value of i = 10
and stop because the condition i<=10 is achieved.
291
value of i = 9
value of i = 10 from functools import reduce
x = [2, 4, 8, 10, 12, 50]
z = reduce (lambda a, b: a+b, x)
print(z)
If the for loop statement:
# 2 + 4 + 8 + 10 + 12 + 50 = 86
is written instead of the statement:
import random
x = random.randint(1,6)
print(x)
▪ Note: the condition i<=10 tells to print till value of i=10 but the
condition i<10 tells to print till value of i=9.
292
import numpy as np
Output:
continues ....
x = ("S", "t", "e", "p", "h", "e", "n", "h", "a", "w", "k", "i", "n", "g")
y = slice(2,5)
print(x[y])
▪ Note:
If the statement:
x = ("S", "t", "e", "p", "h", "e", "n", "h", "a", "w", "k", "i", "n", "g")
cout<<"value of i = "<< i;
y = slice(0, 14, 2)
print(x[y])
cout<<"\n "<< i;
293
1
C Program:
2
#include <stdio.h>
3 int main() {
printf("Albert Einstein\n");
4 printf("Line: %d\n",__LINE__);
printf("Line: %d\n",__LINE__);
5
printf("1905 Papers\n");
return 0;
6
}
7
Output:
8 Albert Einstein
Line: 4
9
Line: 5
10 1905 Papers
294
▪ What will be the output of the following program:
Java program:
#include<iostream>
using namespace std; public class HelloWorld {
return 0; }
} }
• C++ program to print the first ten natural numbers using while loop statement
295
public class HelloWorld {
#include<iostream>
public static void main(String[] args) {
using namespace std;
for (int x=1; x<=5; x++){
int main()
for (int y=1; y<=x; y++)
{
System.out.print("*");
int i = 1;
System.out.println(" ");
while (i<=10)
}
{
}
cout<<"\n "<< i++; Output:
}
}
return 0; *
} **
***
****
*****
The output on the screen is:
5 System.out.print("*");
6 System.out.println(" ");
7 }
8 }
} Output:
9
10
*****
****
***
**
(i<=10) is the condition and *
The statement
Inheritance
is repeatedly executed as long as a given condition (i<=10) is true. The technique of building a new
piece of code on a previously
written piece of code
If the statement:
296
Project-based Learning
int i=1;
Then the compilation error will be displayed on the console screen because initialization is not
defined [i.e., from where to start is not declared].
is replaced by int i = 0;
lbrt nstn prfndly chngd physcs.
0
1 public class HelloWorld {
2 public static void main(String[] args) {
3 System.out.println("Albert Einstein");
4 System.exit(0);
5 }
6 }
7
Output:
8
Albert Einstein
9
10
297
Angular.js
8
do
public class HelloWorld {
{
void mult(int a, int b) {
execute this statement; System.out.println(a*b);
}
} void mult(double a, double b) {
System.out.println(a*b);
while(this is the condition);
}
#include<iostream> void mult(double a, int b) {
using namespace std; System.out.println(a*b);
int main() }
{ public static void main(String args[]) {
int i =1; HelloWorld x = new HelloWorld ();
do x.mult(20,30);
{ x.mult(30.12,12.24); Output:
cout<<" \n i= "<< i++; x.mult(50.15,9);
} while (i<=10); } 600
return 0; } 368.66880000000003
}
451.34999999999997
298
import java.time.LocalDateTime;
i=7
i=8 public class HelloWorld {
i=9 public static void main(String[] args) {
i=10 LocalDateTime x = LocalDateTime.now();
System.out.println(x);
}
}
Output:
The statement:
2022-06-15T07:41:26.512844
cout<<" \ni= "<< i++;
is executed and then condition (i<=10) is checked. If condition (i<=10) is true then
The statement:
is executed again. This process repeats until the given condition (i<=10) becomes false.
299
Django
}
• Program 6.3
C++ program to print the characters from A to Z using for loop, do while loop and while
loop statement.
{ } else {
char a; System.out.println(y);
cout<<" \n"<< a; }
Output:
return 0;
}
Albert Einstein
300
J
K public class HelloWorld {
L public static void main(String[] args) {
M int x = 0;
N for (int i = 1; i <= 50; i++) {
O if (i % 2 == 1) {
P x = x + 1;
Q }
R }
S System.out.println("There are " + x + " odd numbers from 1 to 50");
T }
W }
Output:
X
Y There are 25 odd numbers from 1 to 50
Z
If the statement: for( a=A; a<=Z; a++) is written instead of the statement for( a='A';
a<='Z'; a++) i.e., A is used instead of 'A' and Z is used instead of 'Z', then the compilation
error will be displayed on the screen.
301
▪ C ++ program to print the characters from A to Z using do while loop statement:
{ "March",
Output:
"April",
char a = 'A';
"May",
do
"June",
{ January
"July",
cout<<" \n"<< a++; "August",
} while (a<='Z'); "September",
return 0; "October",
} "November",
"December"
}; System.out.println(months[0]);
}
}
• Program 6.4
302
The output on the screen:
• Program 6.5
303
HAML
If the statement: (HTML Abstraction Markup Language)
string = "Albert"
list = ["Albert", "John", "Mary", "David", "Ram"]
tuple = ("1", "9", "0", "5")
i.e., dictionary = {
"Albert": "Einstein",
#include<iostream>
"Alan": "Turing",
using namespace std;
"Stephen": "Hawking",
int main()
"John": "Calvin",
{ }
int a, b, c; print("The length of string is: ", len(string))
cout<<"Enter any number:"; print("The length of list is: ", len(list))
cin>>b;
c = a % b;
cout <<" the remainder of "<<a <<"and"<< b <<"= "<< c;
return 0;
}
Output:
304
C Program: C Program:
Output: }
0
1 Output:
2
while loop will never get executed
3
Program 6.6
#include<iostream>
using namespace std; Checked Exception Unchecked Exception
int main() An exception thrown at An exception thrown at run-
{
compile time when the time when the executable code
int x, y;
source code is translated into starts running
cout<<"Enter any number:";
cin>>x;
an executable code
cout<<"Enter any number:";
cin>>y;
305
if(x-y==0)
Java program:
{
cout<<"The two numbers are equivalent"; public class HelloWorld {
} public static void main(String[] args) {
else String x = "115";
{ System.out.println( Integer.parseInt( x ));
cout<<"The two numbers are not equivalent"; }
} }
Output:
return 0;
} 115
• Program 6.7
306
{
cout<<"Number is negative";
}
return 0; import java.util.*;
C++ program to print the sum of the first 10 digits using for loop statement
import java.util.*;
Output:
}
return 0;
}
[19, 16, 15, 12, 10]
▪ How the sum of the first 10 digits = 55 is outputted on the screen through the for
Loop statement?
307
i=1 (sum = 0 because the sum is initialized to 0 in the statement int i, sum = 0;)
Is i<=10 true?
Yes, do this
public class HelloWorld {
sum = sum + i = 0 +1 =1
public static void main(String[] args) {
Now,
byte x =65;
i=2 (sum = 1)
char y = (char) x;
Is i<=10 true?
// prints 65
Yes, do this
System.out.println(x);
sum = sum + i = 1 +2 =3
// prints A (ASCII is 65 for A)
Now,
System.out.println(y);
i=3 (sum = 3)
}
Is i<=10 true?
}
Yes, do this
sum = sum + i = 3 +3 = 6
Now,
public class HelloWorld {
i=4 (sum = 6)
public static void main ( String args[]){
Is i<=10 true?
String x;
Yes, do this
int y = 6;
sum = sum + i = 6 + 4= 10
x = (y == 3) ? "Alan" : "Albert";
Now,
System.out. println(x);
i=5 (sum = 10)
}
Is i<=10 true? Output:
}
Yes, do this
sum = sum + i = 10 + 5= 15 Albert
Now,
i=6 (sum = 15)
Is i<=10 true? public class HelloWorld {
Yes, do this public static void main(String[] args) {
sum = sum + i = 15 + 6 = 21 int x;
Output:
Is i<=10 true? }
Yes, do this
sum = sum + i = 28 + 8 = 36 Missing Number: 2
Now,
308
public class HelloWorld {
i=9 (sum = 36) public static void main(String[] args) {
Is i<=10 true? int[] num = { 11, 12, 13, 14, 15 };
Yes, do this int sum = 0;
sum = sum + i = 36 + 9 = 45 for (int x : num)
Now, sum += x;
i=10 (sum = 45) System.out.println(sum);
Is i<=10 true? }
Yes, do this }
Output:
sum = sum + i = 45 + 10 = 55
stops because the condition i<=10 is achieved 65
The statement:
public class HelloWorld {
cout<<"sum of the first 10 digits = "<< sum; public static void main(String[] args) {
String x = "Albert";
int a = 1;
char b = 3;
If the statement: 4
lb
int i, sum = 0;
▪ What will be the output if the for loop statement for(i=1; i<=10; i++) is replaced
by the statement for(i=2; i<10; i++)?
Knowledge engineering
309
If the statement int i, sum, sum = 0; is written instead of int i, sum = 0;
Then the compilation error message will be displayed on the screen (stating that sum is twice
declared). import java.text.SimpleDateFormat;
import java.util.Date;
06-14-2022
• Program 6.9
C++ program to print the average of the first 10 numbers using for loop statement
310
The average of the first10 numbers = 55/10 = 5.5 not 5. But the output on the screen is:
10,000-year clock
The output on the screen:
C++ program to print the product of the first 10 digits using for loop statement
#include<iostream>
using namespace std;
int main()
{
311
int i, product = 1; Algorithmic accountability
for( i=1; i<=10; i++)
product = product * i;
The idea that enterprise
cout<<"the product of the first 10 digits =%d", product; organizations should be held
return 0; answerable for the unfair outcomes
} of their pre-programmed
algorithms
▪ How the product of the first 10 digits = 3628800 is outputted on the screen through
the for Loop statement?
product = product * i = 1 * 2 = 2
x = x + y;
Now,
y = x.substring(0, x.length() - y.length());
i=3 (product = 2)
x = x.substring(y.length());
Is i<=10 true? // print String after swapping
Yes, do this System.out.println(x + " " + y);
product = product * i = 2 * 3 = 6 }
Now, }
312
Is i<=10 true?
Yes, do this
product = product * i = 24 * 5 =120
Now, public class HelloWorld {
i=6 (product =120) public static void main(String[] args) {
Is i<=10 true? String x = "alan turing";
Yes, do this x = x.replace("tu", "");
product = product * i = 120 * 6 = 720 System.out.println(x);
Now, }
i=7 (product =720) } Output:
Is i<=10 true?
Yes, do this alan ring
product = product * i = 720 * 7 = 5040
Now,
i=8 (product =5040)
Is i<=10 true?
Yes, do this
public class HelloWorld {
product = product * i = 5040 * 8 = 40320 public static void main(String[] args) {
Now, for(int x=4; x>=0; x--) {
i=9 (product = 40320) System.out.println();
Is i<=10 true? for(int y=x; y<4; y++) {
313
public class HelloWorld {
public static void main(String[] args) {
double x = 85.78;
is executed to display the output: System.out.println(Math.round(x));
float y = 7777.658999f;
System.out.println(Math.round(y));
the product of the first 10 digits = 3628800
}
}
Output:
86
If the statement: 7778
• Program 7.1
C++ Program to print the table of a number using the for loop statement
314
public class HelloWorld {
int n, i; public static void main(String args1[]) {
cout<<"Enter any number:"; char[] x= {'a', 'l', 'a', 'n', ' ', 't', 'u', 'r', 'i', 'n', 'g'};
▪ How the execution takes its Way through the for Loop statement
CRUSH
Since you entered the number 2, therefore: n=2.
i=1 (Controlled Replication Under Scalable Hashing)
Is i<=5 true?
Yes, print this
2 * 1 = 2 A hash-based algorithm for
using the statement cout<< n <<" * "<< i <<" = "<< n*i; determining how and where
information should be stored and
Now,
retrieved in a distributed object-
i=2
Is i<=5 true? based storage cluster
Yes, print this
2 * 2 = 4
using the statement cout<< n <<" * "<< i <<" = "<< n*i;
Now,
315
i=3
Is i<=5 true?
Yes, print this
2 * 3 = 6
using the statement cout<< n <<" * "<< i <<" = "<< n*i;
Algorithmic transparency
Now,
i=4
Is i<=5 true?
The idea that individuals should
Yes, print this
be able to see or understand the
2 * 4 = 8
using the statement cout<< n <<" * "<< i <<" = "<< n*i;
aspects that influence algorithmic
decisions
Now,
i=5
Is i<=5 true?
Yes, print this
2 * 5 = 10
using the statement cout<< n <<" * "<< i <<" = "<< n*i;
316
Data Vault Modeling
Then the output on the screen is:
If you enter the number 2 (i.e., n=2) A database modelling technique for storing
2 + 3 = 5
Data regarding physical things that are
2 + 4 = 6
tied to a geographical place is collected,
2 + 5 = 7 displayed and manipulated
Geospatial Analytics
will be outputted on the screen.
real 0m0.015s
user 0m0.000s
sys 0m0.004s
n++ executes
[manju@localhost ~]$ time perl -le '$n=0;foreach (1..10) {$n+1}' faster than n+1
real 0m0.016s
user 0m0.000s
sys 0m0.005s
ivar = 365 ;
L value R value
317
C Program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
Output:
int b; 1905
b = atoi(a);
printf("%d\n", b);
return (0);
• Program 7.2
#include<iostream>
using namespace std;
Flexible Deployment:
int main()
{
char M;
A deployment methodology that gives
cout<<"Enter any character:";
cin>>M;
you complete control over how and
cout<<"ch= "<< M; where your applications execute
return 0;
}
318
The output on the screen:
Python code:
Enter any character:
myfunc = lambda x,y : x/y
If you enter the character M
print(myfunc(16, 2))
ch = M
Output:
will be outputted on the screen.
8.0
▪ Note:
M = getchar();
i.e.,
def myfunction(x):
#include<iostream> return lambda y : y * x
using namespace std; a = myfunction(16)
int main() print(a(3))
{
char M;
cout<<"Enter any character:";
Output:
M = getchar();
48
cout<<"ch= "<< M;
return 0;
}
There will be no change in the output on the screen i.e., The output on the screen is:
319
If we replace the statement: cout<<"ch= "<< M; by the statement:
putchar(M);
i.e.,
for x in range(2):
#include<iostream> print (x)
Output:
using namespace std;
0
int main()
1
{
char M;
cout<<"Enter any character:"; for x in range(2,6):
cin>>M; print (x) Output:
2
putchar(M);
return 0; 3
} 4
5
There will be no change in the output on the screen i.e., The output on the screen is:
M = getchar();
Output:
by the statement: 2
5
putchar(M); i.e.,
320
#include<iostream> a = "Albert Einstein was born in Ulm"
using namespace std; b = a.split(' ')
int main() print(b)
{ print(' '.join(b))
char M;
cout<<"Enter any character:";
Output:
M = getchar();
putchar(M); ['Albert', 'Einstein', 'was', 'born', 'in', 'Ulm']
return 0;
Albert Einstein was born in Ulm
}
Answer:
# Python Program to delete a file
import os
#include<iostream>
#include<cmath> os.remove("1.txt")
using namespace std; print("1.txt file does not exist")
int main()
{
int a, b;
a= - 2;
b= abs(a);
cout<<" absolute value of a = "<< b<< endl;
return 0;
}
321
Cluster
The output on the screen:
absolute value of a = 2
A group of interconnected virtual machines is viewed
as a single entity to facilitate load balancing, auto-
scaling, and high availability
• Program 7.2
C ++ program to print the first 5 numbers starting from one together with their squares
#include<iostream>
using namespace std;
int main()
{
int i;
for( i=1; i<=5; i++)
cout<<"\n number = "<< i <<"its square = "<< i*i;
return 0;
}
def myfunc(a):
a.append(15)
a = [12, 13, 14]
Output:
print(a)
The output on the screen:
myfunc(a)
[12, 13, 14]
number=1 its square=1 print(a)
[12, 13, 14, 15]
number=2 its square=4
number=3 its square=9
number=4 its square=16
number=5 its square=25
• How the execution takes its way through the for loop statement
i=1
Is i<=5 true?
322
Yes, print this
number=1 its square=1
using the statement cout<<"\n number = "<< i <<"its square = "<< i*i;
Now,
i=2
Is i<=5 true?
Yes, print this
number=2 its square=4
using the statement cout<<"\n number = "<< i <<"its square = "<< i*i;
Now,
i=3
Is i<=5 true?
Yes, print this
number=3 its square=9
using the statement cout<<"\n number = "<< i <<"its square = "<< i*i;
Now,
i=4
Is i<=5 true?
Yes, print this
number=4 its square=16
using the statement cout<<"\n number = "<< i <<"its square = "<< i*i;
Now,
i=5
Is i<=5 true?
Yes, print this
number=5 its square=25
using the statement cout<<"\n number = "<< i <<"its square = "<< i*i;
Cron job
• Note:
A Linux command that allows us to schedule tasks to be
If the statement
executed at a later time in future
323
cout<<"\n number = "<< i <<"its square = "<< i*i;
122880
Suppose cout<<"\n number = "<< i <<"\t its square = "<< i*i; is replaced by the
statement
Bare-metal
324
Bastion host
number=3
its square=9
number=4
its square=16 A specialized server that is intentionally accessible to the public
number=5
network and is configured to survive cyberattacks
its square=25
▪ Write a program to print the first 10 numbers starting from one together with their
squares and cubes?
def myfunc(**kwargs):
for i, x in kwargs.items():
print(i + ": " + x)
Answer: myfunc(physicist = "Stephen", cosmologist = "William", author = "Hawking")
#include<iostream>
Output:
using namespace std;
physicist: Stephen
int main()
cosmologist: William
{
author: Hawking
int i;
for( i=1; i<=10; i++)
cout<<"number = "<< i <<" its square = "<< i*i <<" its cube = "<< i*i*i<< endl;
return 0;
}
• Program 7.3
import pandas as pd
a = pd.Series([3, 4, 13, 30, 13])
#include<iostream> b = pd.Series([13, 13, 30, 27, 29])
using namespace std; a=a[~a.isin(b)]
int main() print(a) Output:
{
int x, *p;
0 3
cout<<"Enter any integer:";
1 4
cin>>x;
dtype: int64
325
# union of series
p = &x;
cout<<"The address of the variable x = "<< p;
import pandas as pd
cout<<"The value of the variable x = "<< *p;
import numpy as np
return 0;
a = pd.Series([3, 4, 13, 30, 13])
}
b = pd.Series([13, 13, 30, 27, 29])
c= pd.Series(np.union1d(a, b))
print(c)
# intersection of series
import pandas as pd
i.e.,
import numpy as np
#include<iostream> a = pd.Series([3, 4, 13, 30, 13])
using namespace std; b = pd.Series([13, 13, 30, 27, 29])
int main() c= pd.Series(np.intersect1d(a, b))
{ print(c)
int x, *p; Output:
cout<<"Enter any integer:";
cin >> x; 0 13
p = &x; 1 30
dtype: int64
326
cout<<"The address of the variable x = "<< p <<"its value = "<< *p;
return 0;
}
C program:
#include<iostream>
using namespace std; #include <stdio.h>
int main() int main() {
{ int x =25;
int x, y, *p, *q, sum; (x>=56)? (printf("Albert")) : (printf("Einstein"));
cout<<"Enter any number:"; return 0;
cin >> x; }
cout<<"Enter any number:"; Output:
cin >> y;
p = &x;
Einstein
q = &y;
sum = *p + *q;
cout<<"\n sum of entered numbers = "<< sum;
return 0;
}
#include <stdio.h>
int main() {
int x =151;
Output:
Enter any number:
327
sum of entered numbers = 7
• C++ program to print the product, subtraction and division of two numbers using
pointers
#include<iostream>
using namespace std; #include<stdio.h>
int main() #define solve(s,t,u,m,p,e,d) m##s##u##t
{ #define start solve(a,n,i,m,a,t,e)
int x, y, *p, *q, product, subtract, div;
cout<<"Enter any number:"; int start() {
cin>> x; printf("Albert Einstein");
cout<<"Enter any number:"; return 0;
cin>> y; }
p = &x; Output:
q = &y;
product = *p * *q; Albert Einstein
subtract = *p - *q;
div= *p / *q;
cout<<"\n product of entered numbers = "<< product;
cout<<"\n subtract of entered numbers = "<< subtract;
cout<<"\n division of entered numbers = "<< div;
return 0;
} #include <stdio.h>
int main() {
float x = 6.77;
int y = (int)x+1;
The output on the screen: printf("%d\n", y);
return 0;
}
Enter any number:
If you enter the number 4 Output:
Enter any number:
If you enter the number 2 7
product of entered numbers = 8
328
subtract of entered numbers = 2
division of entered numbers = 2
#include<iostream>
using namespace std;
int main()
#include<stdio.h>
{
#include<string.h>
int x, y, *p, *q;
#include<ctype.h>
cout<<"Enter any integer:";
cin>> x;
int main() {
cout<<"Enter any integer:";
char a[]="Albert";
cin>> y;
char b[]=" Einstein";
p = &x;
printf("%s", strcat(a, b));
q = &y;
return 0;
if(*p>*q)
}
{
cout<<"x is greater than y";
Output:
}
else
Albert Einstein
{
cout<<"y is greater than x";
}
return 0;
}
329
If you enter the integer 16
y is greater than x
will be outputted on the screen.
#include<stdio.h>
int main() {
A)
int x = 3;
}; }
Answer:
B)
#include <iostream>
using namespace std;
int main() Cycle Stealing
{
int x, t, c;
x=12;
A technique for accessing RAM without
t=2;
c = x/t; disrupting the CPU
cout<<"velocity = "<< c <<"m/s";
return 0;
330
}
Answer:
velocity = 6 m/s
• Program 7.4
Single-bit error:
#include<iostream>
using namespace std; A single bit of a data is altered from 1 to 0 or 0 to 1
int addition();
Burst Error:
int main()
{ 2 or more bits of data are altered from 0 to 1 or 1 to 0
int answer;
answer = addition();
cout<<"The sum of two numbers is: "<<answer;
return 0;
}
#include<stdio.h>
int main() {
int addition()
int x = 7;
{
if(x = x - 7 > 3) {
int x, y;
printf("Albert");
cout<<"Enter any integer:";
}
cin>>x;
else {
cout<<"Enter any integer:";
printf("Einstein");
cin>>y;
}
return x+y;
return 0;
}
}
Output:
Einstein
The output on the screen:
331
Python code:
Enter any integer:
If you enter the integer 3
a = ('Albert', 1905, 'Papers')
Enter any integer:
b = ['Albert', 1905, 'Papers']
If you enter the integer 5
print(a[0])
sum of two numbers = 8
print(b[1])
will be displayed on the screen. Output:
Albert
1905
a = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
a = 50 # Global-scope variable
int multiplication() def myfunc():
{ a = 100 # Local-scope variable
int x, y; print(a)
cout<<"Enter any integer:"; print(a)
cin>>x; myfunc()
cout<<"Enter any integer:"; print(a)
cin>>y; Output:
return x*y; 50
} 100
50
332
b = [1, 2, 3, 4, 5]
If you enter the integer 3
a = [i**2 for i in b]
Enter any integer: print(a)
{ a = [i%2 for i in b]
int x, y; print(a)
333
Enter any integer:
If you enter the integer 3
Enter any integer: Retransmission:
If you enter the integer 5
largest of two numbers= 5 A method in which the receiver identifies an error and
will be outputted on the screen. requests that the sender resend the message
#include<iostream>
Unicast transmission
using namespace std;
int largest();
int main()
{
int answer;
The data is sent from a single source to
answer = largest();
cout<<"largest of three numbers= "<< answer; a single recipient
return 0;
}
int largest()
{
b = [1, 2, 3, 4, 5]
int x, y, z;
a = {i:i**2 for i in b}
cout<<"Enter any integer:";
print(a)
cin>>x;
cout<<"Enter any integer:";
cin>>y; Output:
cout<<"Enter any integer:";
cin>>z; {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
if(x>y&& x>z)
return x;
if(y>x&& y > z)
return y;
if(z>x && z>y)
return z;
}
334
p = [3, 5, 7]
#include<iostream>
using namespace std;
int square(;
int main()
{
int answer;
answer = square();
cout<<"square of the number = "<< answer;
return 0;
} p = [3, 5]
int square() q = [9, 11]
{ r = [(a,b) for a in p for b in q]
int x; print(r)
cout<<"Enter any integer:";
Output:
cin>>x;
return x*x;
[(3, 9), (3, 11), (5, 9), (5, 11)]
}
335
The output on the screen:
Answer:
#include <iostream>
using namespace std;
int main()
{ Output:
int a = 32;
int& b = a; a = 62
b = 62;
cout << "a = " << a << endl;
return 0;
}
336
• Program 7.5
C++ has an inbuilt multiple branch selection statement [called switch] which successively
tests the value of an expression against a list of integer or character constants. When a
match is found, the statement sequences associated with that constant are executed.
Switch(case)allows us to make decision from the number of choices i.e., from the
number of cases.
For example:
#include<iostream>
using namespace std;
int main()
{
char ch;
cout<<"Enter any character:"; Self-Serving Data
cin>>ch;
switch(ch)
{
case 'R':
cout<<"Red";
break; Making data accessible to data users for statistical
case 'W': and research purposes, allowing them to generate
cout<<"White"; and build their own data analysis, as well as
break;
modify and adapt judgments based on it
case 'Y':
cout<<"Yellow";
break;
case 'G':
cout<<"Green";
break;
default:
cout<<"Error";
break;
}
return 0;
337
}
C program:
Output:
case 'R':
cout<<"Red";
K
break;
k
case 'W':
cout<<"White"; 2
break;
case 'Y':
cout<<"Yellow";
break; #include<stdio.h>
break;
}
#include<stdio.h>
int main() {
are replaced by the statements: Output:
int a;
a=printf("Alan"); Alan4
case 'R': printf("%d", a);
cout<<"Red"; return 0;
case 'W':
cout<<"White"; }
338
case 'Y': #include <stdlib.h>
cout<<"Yellow"; #include <stdio.h>
break;
case 'G': int main() {
cout<<"Green"; char a = 'K';
break; if(a =='A') { Output:
default: exit(0); K
cout<<"Error"; } else {
break; printf("K");
}
return 0;
}
Then the output on the screen is:
Red
White
Yellow
i.e., the output will be printed till yellow even though you have entered the character R.
• In C, a switch can have at least 257 case statements. C++ recommends that at least 16,384 case statements
be supported.
Arrays provide a more convenient way of storing variables of a similar data type together instead of storing them
separately. Each value of the array will be accessed separately.
#include<stdio.h>
int main(){
339
Element [2] = 20 #include<stdio.h>
int main() {
Element [3] = 25 int a = 20;
printf("%d\n%d\n%d\n", a++,a,++a);
Element [4] = 36
return 0;
using arrays: } Output:
21
22
#include<iostream>
using namespace std;
22
main()
{
int i;
int num [5] = {16, 18, 20, 25, 36};
for(i=0; i<5; i++)
cout<<"Element ["<< i <<" ] = "<< num[i] << endl;
return 0;
}
#include <stdio.h>
int main() {
int a;
The output on the screen:
int b= 1;
Element [0] = 16 int m[3] = { 1, 2, 3};
Element [1] = 18 a = 5 * 6 + m[b+1] - (6 / b);
Element [2] = 20 printf("%d", a);
Element [3] = 25 return 0; Output:
Element [4] = 36 }
27
340
#include<stdio.h>
Then the output on the screen:
#include <stdio.h>
The output on the screen: int main(void) {
Output:
printf("Ala\bn");
Ala•n
return 0;
}
Element [0] = 18
Element [1] = 18
Element [2] = 18 #include <stdio.h>
Element [4] = 18 {
while (printf("Albert Einstein"))
return 0;
} Output:
341
cout<<"Element ["<< i <<" ] = "<< num[2] << endl;
#include <stdio.h>
The output on the screen: int main(){
extern int x;
printf("%d", x);
Element [0] = 20
return 0;
Element [1] = 20
}
Element [2] = 20
int x = 52;
Element [3] = 20 Output:
Element [4] = 20
52
cout<<"Element ["<< i <<" ] = "<< num[i] << endl; is replaced by the statement:
342
The output on the screen: Data Culture
Element [0] = 36
Element [1] = 36
The collective behaviors, views, attitudes and convections of
Element [2] = 36
individuals in an enterprise organization who respect, value,
Element [3] = 36
Element [4] = 36
practice and support the use of data to improve data-driven
decision-making and solve data-related issues
If the condition:
i<5
Parallel Programming
is replaced by the condition:
(The programming paradigm)
i<=5
Element [0] = 16
Element [1] = 18
Element [2] = 20
Element [3] = 25
Element [4] = 36
Element [5] = 3656
3656 is the number stored in the memory i.e., any number stored in the memory will be
displayed.
If the statement:
int num [5] = {16, 18, 20, 25, 36}; is replaced by the statement:
343
int num [i] = {16, 18, 20, 25, 36};
Then the compilation error will be displayed on the screen because there are 5 elements within
the braces {} not i elements.
C Program:
#include <stdio.h>
Output:
int main() {
int a =13;
Odd
(a&1)?printf("Odd"):printf("Even");
return 0;
C++ Program:
#include <iostream>
using namespace std;
int main() {
cout<<mult(4,5)<<endl;
cout<<mult(2,6,1)<<endl;
return 0;
344
Java Program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Albert Einstein"); Output:
} Albert Einstein
public static void main(String args) {
System.out.println("Alan Turing");
}
}
#include<iostream>
using namespace std;
Management Information Systems
int main()
{
int i, sum = 0;
int num [5] = {16, 18, 20, 25, 36};
The method of delivering appropriate data to
for(i=0; i<5; i++)
sum = sum + num[i]; conduct day-to-day business operations and
cout<<"Sum of the Elements in the array = "<< sum; track an enterprise organization's growth
return 0;
}
345
Then The output on the screen:
Python code:
#include<iostream>
using namespace std; x = [11, 12, 13, 14, 15, 16]
int main() print(x[-1])
{ print(x[-2])
int i, avg, sum = 0; Output:
int num [5] = {16, 18, 20, 25, 36}; 16
for(i=0; i<5; i++) 15
sum = sum + num [i];
avg = sum/5;
cout<<"Sum of the Elements in the array = "<< sum;
cout<<"average of the elements in the array= "<< avg;
return 0;
}
import pandas as pd
a = {'Albert' : 1879, 'Turing' : 1912, 'Newton' : 1643}
▪ Write a program to print: b = pd.Series(a) Albert 1879
print (b) Turing 1912
Newton 1643
Einstein [0] = E dtype: int64
import pandas as pd
Einstein [1] = I
a = {'Albert' : 18.79, 'Turing' : 19.12, 'Newton' : 16.43}
346
Einstein [4] = T C program:
Einstein [6] = I
int main() {
Einstein [7] = N
int x=0;
while (10 - x++)
printf ("\n %d", x);
using arrays
return 0;
}
Output:
Answer: 1
2
3
#include<iostream>
4
using namespace std;
5
int main()
{
6
int i; 7
char name [8] = {'E' , 'I', 'N', 'S', 'T', 'E', 'I', 'N'}; 8
for(i=0; i<8; i++)
9
cout<<"Einstein ["<< i <<" ] = "<< name[i] << endl;
10
return 0;
}
i)
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout<<""<< cbrt(27);
return 0;
347
}
Answer:
3
C program:
ii)
#include <stdio.h>
int main() {
int a = 19, b = 2;
#include <iostream> double c;
using namespace std; c = (double) a / b;
int main() printf("%f\n", c );
{ return 0;
char i; }
char body [4] = {'b', 'o', 'd', 'y'}; Output:
for(i=0; i<4; i++)
cout<<"\n body ["<<body[i] <<" ] = "<< body[i] << endl;
9.500000
return 0;
}
iii) }
348
#include <iostream>
#include <malloc.h>
using namespace std; #include <stdio.h>
int main() int main() {
{ for (int a=1; a<=3; a++)
int x=2; printf ("%d", a*a);
cout<<""<< malloc (200*sizeof(x)); return 0;
return 0; }
}
#include <stdio.h>
int main() {
int a=1;
while (a<=3) {
Answer:
printf ("%d", a * a);
8183824 a++;
}
return 0;
}
Program 7.7
using structures
#include <stdio.h>
#include <string.h>
int main () {
#include<iostream>
int x, y;
using namespace std;
x=strlen("Albert");
int main()
y=sizeof("Albert"); Output:
{
printf("%d %d", x, y);
struct book {
return 0; 67
char name;
}
float price;
int pages;
349
int edition;
};
struct book b1= {'B', 135.00, 300, 8};
cout<<"Name of the book = "<< b1.name<< endl;
cout<<"Price of the book = "<< b1.price<<endl;
cout<<"Number of pages = "<< b1.pages<<endl;
cout<<"Edition of the book = "<< b1.edition<< endl;
return 0;
#include <stdio.h>
}
void num(int, int);
int main() { Calling a function by
int x=56, y=106; passing the values of
num(x,y); variables
The output on the screen:
printf("%d \n", x);
#include <stdio.h>
A) void num(int*,int*);
Calling a function by
int main() {
#include<iostream>
passing references of
int x=56,y=106;
using namespace std;
variables
num(&x, &y);
struct book {
char name; printf("%d \n", x);
printf("%d \n", y);
float price;
return 0;
int pages;
}
int edition;
void num(int *p, int *q) {
};
*p=25;
int main()
{
*q=36;
Output:
}
struct book b1;
b1.name = 'C'; 25
b1.price = 135.00; 36
b1.pages = 300;
350
b1.edition = 8;
cout<<"Name of the book = bulgarian "<< b1.name << endl;
cout<<"\n Price of the book = "<< b1.price;
cout<<"\n Number of pages = "<< b1.pages<<endl;
cout<<"\n Edition of the book = "<< b1.edition;
}
C program:
#include <stdio.h>
Answer: #define m(a, b) a##b
B) 560
#include <iostream>
using namespace std;
int main() {
C program:
for( ; ; ) {
#include <stdio.h>
cout<<"This loop will run forever.\n";
} int main() {
int a = 32;
return 0; if (a && ((a & a-1) == 0)) {
}
return 0;
Answer:
}
351
This loop will run forever.
This loop will run forever.
This loop will run forever.
......... continues
• Program 7.8
i)
#include <iostream>
using namespace std;
int main() C Program:
{
int i; #include <stdio.h>
for (i=1; i<=5; i++) #define xyz main
{
if (i==3) int xyz ()
{ {
continue; printf("Albert Einstein");
} return 0;
352
5
ii)
#include <iostream>
using namespace std;
int main()
C program:
{
int i; #include <stdio.h>
for (i=1; i<=5; i++) int main() {
{ int num[3]={11,12,13};
if (i==3) for(int x=0;x<3;x++) {
{ printf("%d", num[x]);
break; }
} return 0;
cout<<"\n "<< i; }
}
return 0; Output:
}
11 12 13
1
2
• Program 7.9
C++ program to convert the upper case letter to lower case letter
353
#include<iostream>
Python code:
Output:
using namespace std;
a = "manjunath5496".isalnum()
int main()
print(a) True
{
char ch = 'A';
char b = tolower(ch);
cout<<" upper case letter "<< ch <<" is converted to lower case letter "<< b;
return 0;
}
If you want to enter the character through the keyboard, then the above program should take the
form:
Python code:
#include<iostream>
a = "$manju@123".isalnum()
Output:
using namespace std;
print(a)
int main() False
{
char ch;
cout<<"Enter any character:";
cin>>ch;
char b = tolower(ch);
cout<<" upper case letter "<< ch <<" is converted to lower case letter "<< b;
return 0;
}
import re
a = bool(re.match('[A-Za-z0-9]+$','manju1988'))
print(a)
354
upper case letter C is converted to lower case letter c will be outputted on the
screen.
• Program 8.0
C++ program to convert the lower case letter to upper case letter
import re
def m(date):
If you want to enter the character through the keyboard, then the above program should take
the form: from datetime import datetime
#include<iostream>
a = datetime.strptime("1988-03-01", "%Y-%m-%d").strftime("%d:%m:%Y")
using namespace std;
print(a)
int main()
{ Output:
char ch;
cout<<"Enter any character:";
01:03:1988
cin>>ch;
char b = toupper(ch);
cout<<" lower case letter "<<ch<<" is converted to upper case letter "<<b;
355
return 0; from collections import Counter
}
a ={'Albert': 25, 'John': 50, 'Alan': 75}
b = {'Newton': 100, 'Einstein': 125, 'Turing': 150}
c = Counter(a) + Counter(b)
Output on the screen:
print(c)
Enter any character:
Counter({'Turing': 150, 'Einstein': 125, 'Newton': 100, 'Alan': 75, 'John': 50, 'Albert': 25})
+ - * / % ^
& | ~ ! , =
+= −= /= %= ^= &=
|= *= <<= >>= [] ()
:: .* . ?:
• Program 8.1
356
C++ program to test whether the entered character is upper case letter or not
#include<iostream>
using namespace std;
int main()
{
char ch = 'a';
if(isupper(ch))
cout<<"you have entered the upper case letter";
else
cout<<"you have entered the lower case letter";
return 0;
} C program:
#include <stdio.h>
int main() {
Output on the screen: int x = 4, y = 4;
printf("!(x == y) is %d \n", !(x == y));
you have entered the lower case letter
return 0;
}
char ch = 'A';
• Program 8.2
C++ program to test whether the entered character is lower case letter or not
357
#include <stdio.h>
int main() {
#include<iostream>
int x = 4, y = 4, z = 5;
using namespace std;
printf("(x != y) || (z < y) is %d \n", (x != y) || (z < y));
int main()
return 0;
{
char ch = 'a'; }
if(islower(ch))
cout<<"you have entered the lower case letter";
else
cout<<"you have entered the upper case letter";
return 0;
} Output:
(x != y) || (z < y) is 0
• Program 8.3
C++ program to print the value of tan inverse x (i.e., the value of tan−1 x)
#include <stdio.h>
#include<iostream> int main() {
#include<math.h> int x = 4, y = 4, z = 5;
using namespace std; printf("(x == y) || (z < y) is %d \n", (x == y) || (z < y));
int main() return 0;
{ }
int x = 20;
cout<<"the value of tan inverse x = "<< atan(x);
return 0;
}
Output:
(x = = y) || (z < y) is 1
Output on the screen:
358
• Program 8.4
x x
C++ program to print the value of tan inverse (i.e., the value of tan−1 y )
y
C program:
#include<iostream>
#include <stdio.h>
#include<math.h>
int main() {
using namespace std;
int x = 4, y = 4, z = 5;
int main()
printf("(x == y) && (z > y) is %d \n", (x == y) && (z > y));
{
return 0;
int x, y;
}
x = 20; Output:
y =20;
cout<<"the value of tan inverse x/y = "<< atan2(x,y); (x = = y) && (z > y) is 1
return 0;
}
C program:
359
Output on the screen:
C program:
• Program 8.6
#include <stdio.h>
C++ program to print the value of ~x
int main() {
#include<iostream> int x = 4, y = 4, z = 5;
using namespace std; printf("%d >= %d is %d \n", x, y, x >= y);
int main() printf("%d >= %d is %d \n", x, z, x >= z);
{
return 0;
int x, y;
}
x = 205; Output:
y=~x;
cout<<"the value of y is: "<< y; 4 >= 4 is 1
return 0; 4 >= 5 is 0
}
y= −(~x);
(x == y) && (z < y) is 0
360
the value of y is: 206
i)
C program:
#include<iostream>
#include <stdio.h>
using namespace std;
int main() {
int main()
int x = 4, y = 4, z = 5;
{
printf("%d == %d is %d \n", x, y, x == y);
int i = 54;
printf("%d == %d is %d \n", x, z, x == z);
int y = i<<1;
return 0;
cout<<"The value of y = "<< y;
}
return 0;
} Output:
4 = = 4 is 1
4 = = 5 is 0
Answer:
If the statement:
#include <stdio.h>
The value of y = 216
int main() {
int x = 4, y = 4, z = 5;
printf("%d > %d is %d \n", x, y, x > y);
printf("%d > %d is %d \n", x, z, x > z);
ii)
return 0;
}
#include<iostream> Output:
using namespace std; 4 > 4 is 0
int main() 4 > 5 is 0
361
C program:
{
int i = 54; #include <stdio.h>
int y = i>>1; int main() {
cout<<"The value of y = "<< y; int x = 4, y = 4, z = 5;
return 0; printf("%d < %d is %d \n", x, y, x < y);
} printf("%d < %d is %d \n", x, z, x < z);
return 0;
}
Output:
Answer:
4 < 4 is 0
If the statement:
C program:
4 != 4 is 0
4 != 5 is 1
• Program 8.7
C++ program to print the length of the entered character (i.e., to print the length of the
string)
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
362
char ch[4];
cout<<"Enter any word: ";
cin>>ch;
cout<<"The length of the string = "<< strlen(ch);
return 0;
}
Dogpile effect
(A sort of cascading failure)
will be displayed on the console screen because there are three letters in the word
dog.
will be displayed on the console screen because there are four letters in the word tech.
363
Binary tree
Garbage Collection
Number of unlabeled binary trees possible with 'x' unlabeled nodes = 2xCx / x +1
For x = 3:
2x! 6! 6×5×4×3×2×1
2x
Cx = = = = 20
x! (2x−x)! 3! (6−3)! (3×2×1) ×(3×2×1)
20
Number of unlabeled binary trees possible with '3' unlabeled nodes = =5
(3 + 1)
Number of labeled binary trees possible with 'x' labeled nodes = (2xCx / x +1) × x!
For x = 3:
364
• Program 8.8
C program:
#include<iostream> Output:
using namespace std;
#include <stdio.h>
int main () { 14.000000
int main()
{ int p = 14;
int i, n, fact=1 ; float q = p;
cout<<"Enter any number:"; printf("%f", q);
cin>>n; return 0;
for(i=1; i<=n; i++)
}
fact = fact *i;
cout<<"\n Entered number is: "<< n;
cout<<"\n The factorial of the entered number"<<n<<"is:"<< fact;
return 0;
}
Output:
Entered number is: 4
14
The factorial of the entered number 4 is: 24
365
The Single Responsibility Principle
Each 1 or 0 in a binary number is called a bit
Errors
Logic Errors − The program runs, but does not produce the expected results
• Include: Using an incorrect formula, incorrect sequence of statements
366
• Comprehend the issue
• Devise a plan
Problem solving steps
• Carry out the plan
• Audit the outcomes
Software
All systems models have flaws, but as long as they don't have too Rather than being organized on technologies,
many flaws, they can be useful teams are organized around features
367
Kernighan's Law: Debugging is twice
Source Code Compiler
as difficult as writing the code itself
Translator
Intermediate program
Program Execution
Machine language
Java Compiler
(Tesler's Law):
Premature Optimization
Output
Each application has a certain level of inherent
complexity that cannot be eliminated or concealed
We start optimizing before we
even realise we need to
368
Data type that stores two types of values (0 and 1).
Boolean
• 0 represents false value and 1 represents true value
Dunbar's number
150
int main() {
bool x = false;
if(x){
printf("x is true."); If you don't include this
} header file, the program will
else{ not compile
printf("x is false.");
}
}
369
Sequence control structure Selection control structure
• Hang up
Or ELSE Forget the whole thing
The instruction
mov al, 061h
implies:
Assembly Level Language
Move the hexadecimal value 61 (97 decimal) into the processor register named "al"
Amara's Law
We tend to overestimate the technology's short-term impact and underestimate its long-term impact
Postel's Law
Sarnoff's Law: The utility of a broadcast network
rises in direct proportion to the number of viewers (Robustness Principle)
370
Start The Liskov Substitution Principle:
Yes No
If A > B
Print A Print B
End
Limitations of Flowchart
• If the program logic is quite complicated, then flowchart becomes complex and clumsy.
• In the event that modifications are required the flowchart may require re-drawing totally.As the flowchart
symbols can't be typed, reproduction of flowchart turns into an issue.
371
String x = "32";
int y = Integer.parseInt(s1); // y now holds 32
String x = "32";
double y = Double.parseDouble(s1); // y now holds 32
Parkinson's Law:
a <<= b → a × 2b
#include<stdio.h>
}
• V = The utility of a network
• B = The benefit a network offers
• C = The expense of providing the network
• SI = Security investment that a enterprise organization spends in order
Output on the screen:
to minimize losses
a >>= b → a × 2−b
Gall's Law: A complicated system
that works is developed from a
simpler system that worked
372
#include<stdio.h>
main()
{
The Broken Windows Theory: Poor
int a, b, c; quality code can give the impression that
a=2; efforts to improve it are being neglected or
b=2; devalued, leading to even worse code
c = a <<= b;
The value of c = %
90−9−1 Principle
• no functions — declare static methods Ninety percent of people just consume content,
while nine percent alter or modify it, and one
• no global variables — public static variables
percent adds it
• no destructors — garbage collection and finalize
373
Heap: Dynamically allocated global memory
Kerckhoff's principle:
Java does not support multiple inheritance In cryptography, a system should be secure even if
everything about it is widely known except for a
little piece of information called the key
Conway's Law:
Hoare's Law of Large Programs:
Any piece of software is a representation of the organizational structure
Every huge problem contains a little
that created it
problem that is attempting to escape
• Internal Sort: The data to be sorted is stored in the computer's main memory
• In Place Sort: The amount of extra space required to sort the data is constant with the input size
Ninety–ninety rule:
The first 90% of the code consumes 10% of the time to complete
The remaining 10% of the code consumes the remaining 90% of the time to complete
374
• Problem definition
• Problem analysis
• Coding
Problem solving methodology
• Program testing and Debugging
• Documentation
• Program maintenance
Hick-Hyman Law:
How does Machine learning Work? The higher the number of options presented to users, the longer it
will take them to make a selection
Find patterns
Prediction
Build
Logical
models Metcalfe's Law:
Evaluation
375
7 Steps of Machine Learning: Linus's Law:
• Choose a model
• Evaluation
Brooks' Law
• Hyperparameter Tuning
• Prediction
Adding workforce to a late software
project only delays it
3 Main techniques of Machine Learning:
• Supervised Learning
ML
Known Data Processing
Algorithm
Trained model
Production Verification
Unknown Data
376
• Unsupervised Learning Gilder's Law: Every twelve months, the total
bandwidth of communication systems triples
Unknown ML
Processing
Data Algorithm
Apple
? Response Feedback Learns
Input
Bell's Law:
377
Hypponen's Law: Every time a device Fitt's Law:
is described as "smart," it is vulnerable
The time it takes for a pointer to move from its present position to a
target is proportional to the target's distance and size
Cunningham's Law
Kryder's Law:
Every thirteen months, the amount of data a disc can hold doubles
Machine Learning
Pre-categorized data Unlabeled data
Supervised Unsupervised
Classification
Regression
(Divide the items by color)
(Divide the items by length)
378
Location where all the
configuration files are uploaded
Chef client is the key
component of Chef node − which helps
Chef server
Knife (command-line tool) is used in setting up the communication
(Centralized store of
to upload configuration file to the between the Chef server and Chef node
Infrastructure configuration)
Chef server
Libraries Libraries
App App
App App
Libraries
Libraries Libraries
Kernel
Kernel
379
• Deploying applications on host: All the applications will share the same libraries present in the
operating system.
• Deploying applications on container: All the applications have the necessary libraries isolated
from the rest of the operating system and cannot be intervened by any other application. If one
application crashes, other application will keep running flawlessly and won't experience any
technical issues. This isolation also decreases security risks: If one application is hacked or
breached by malware (including viruses, ransomware and spyware), any resulting negative
outcomes won't spread to the other applications.
Reed's Law:
Speed
Security applied
DevOps Development Process:
Security applied
380
Linux
Developer Community
Linus Torvalds
Linus Torvalds
Working state Current
Marketing target Cloud computing, embedded devices, mainframe computers, mobile devices, personal
Available in Multilingual
Platforms Alpha, ARC, ARM, C6x, AMD64, H8/300, Hexagon, Itanium, m68k, Microblaze, MIPS, ND
Userland GNU
Linus Torvalds
License GPLv2 and others (the name "Linux" is a trademark)
Creator of Linux
366
381
What is Linux and why is it so popular?
Whether you know it or not you are already using Linux (the best-known and most-used open
source operating system) every day. From supercomputers to smartphones, the Linux operating
system is everywhere. As an operating system, Linux is a family of open source Unix-like
software based on the Linux kernel - that sits underneath all of the other software on a computer,
receiving requests from those programs and relaying these requests to the computer's hardware.
With regard to careers, it is becoming increasingly valuable to have Linux skills rather than just
knowing how to use Windows. In general, Linux is harder to manage than Windows, but offers
more flexibility and configuration options.
Every desktop computer uses an operating system. The most popular operating systems in use
today are: Windows, Mac OS, and LINUX. Linux is the best-known notoriously reliable and
highly secure open source portable operating system -- very much like UNIX -- that has become
very popular over the last several years -- created as a task done for pleasure by Linus Torvalds -
- computer science student at the University of Helsinki in Finland -- in the early 1990s and
later developed by more than a thousand people around the world.
Linux is fast, free and easy to use, that sits underneath all the other software on a computer −
runs your computer -- handling all interactions between you and the hardware i.e., whether
you're typing a letter, calculating a money budget, or managing your food recipes on your
computer, the Linux operating system (similar to other Operating Systems, such as Windows XP,
Windows 7, Windows 8, and Mac OS X) provides the essential air that your computer breathes.
Linux is the most important technology advancement of the twenty-first century and Licensed
under the General Public License (GPL) that Linux uses ensures that the software will always be
open to anyone and whose source code is open and available for any user to check, which makes
it easier to find and repair vulnerabilities and it power the laptops, development machines and
382
367
servers at Google, Facebook, Twitter, NASA, and New York Stock Exchange, just to name a
few. Linux has many more features to amaze its users such as: Live CD/USB, Graphical user
interface (X Window System) etc.
Although Microsoft Windows (which is the most likely the victim of viruses and malware) has
made great improvements in reliability in recent years, it considered less reliable than Linux.
Linux is notoriously reliable and secure and it is free from constant battling viruses and malware
(which may affect your desktops, laptops, and servers by corrupting files, causing slow downs,
crashes, costly repairs and taking over basic functions of your operating system) – and it keep
yourself free from licensing fees i.e., zero cost of entry ... as in free. You can install Linux on as
many reliable computer ecosystems on the planet as you like without paying a cent for software
or server licensing. While Microsoft Windows usually costs between $99.00 and $199.00 USD
for each licensed copy and fear of losing data.
CD-ROM
(Compact disc read-only memory)
Below are some examples of where Linux is being used today:
383
368
Collaborative management: A working partnership between Internet
commerce partners and Internet service providers to ensure that commercial
transactions are completed successfully
• Kernel
Kernel is the core part of Linux Operating System and interacts directly with hardware. It is
responsible for all major activities of the Linux operating system.
• System Library
System libraries are special programs using which application programs accesses Kernel's
features.
Closedown
• System Utility
Now Linux (successfully being used by several millions of users worldwide) has grown passed
the stage where it was almost exclusively an academic system, useful only to a handful of people
with a technical background. It provides more than the operating system: there is an entire
infrastructure supporting the chain of effort of creating an operating system, of making and
testing programs for it, of bringing everything to the users, of supplying maintenance, updates
and support and customizations, runs on different platforms including the Intel and Alpha
platform. Today, Linux is ready to accept the challenge of a fast-changing world to do various
384
368
types of operations, call application programs etc. Since the hiring focus is shifting more and
more toward DevOps type skills, a Linux skill set will be the types of things that will make you
very deployable.
The command-line interface is one of the nearly all well built trademarks of Linux. There exists
an ocean of Linux commands, permitting you to do nearly everything you can be under the
impression of doing on your Linux operating system. Although, this to the end of time creates a
problem: by all of so copious commands accessible to manage, you don't comprehend where and
at which point to fly learning them, especially when you are learner. If you are facing this
problem, and are peering for a painless method to begin your command line journey in Linux,
you've come to the right place, we will launch you to a hold of well liked and helpful Linux
commands.
Breakpoint: A point in a software program at
which the code stops execution
Description:
Command:
date
Command:
cal
385
370
Description:
Command:
Read operation:
Description:
Any action that retrieves data
Display August month 2016 year calendar. without changing it in any way
Command:
cal 8 2016
Description:
Command:
clear
Database mirroring
exit
386
371
Cross-compiler: A compiler that runs on one platform
but produces executable code for another platform
Description:
Command:
free
Description:
Command:
free -b
Description:
Command:
free -k
Description:
Access control list: A set of
Display free and used system memory in megabytes. rules that determines who has
access to a system resource and
who does not
Command:
387
372
free -m
Command:
passwd
Description:
Command:
shutdown
Command:
shutdown -h now
Eviction: A methodology of
removing a piece of data
Description:
from a cache
Power-off the machine after 10 minutes.
388
373
Command:
shutdown -h +10
Cache invalidation
Description:
The process of replacing or
Print current working directory. eliminating entries from a cache
in a computer system
Command:
echo $PWD
Description:
Command:
echo $OLDPWD
Description:
Command:
389
374
Description: Write operation: Any database
Command:
history
Description:
Command:
sudo reboot
Command:
ip address
Description:
Command:
ls -s
390
375
Read-only Transaction
Description:
mount
Description:
Command:
du
Description:
Command:
uptime
391
376
date --set 1998-11-02
Description:
Command:
Command:
fdisk -l /dev/sda
Description:
Command:
ls
377
392
Command:
ps
Description:
Command:
df
Description:
Command:
df -H
Description:
Command:
rm -r *
393
378
Description:
Command:
top
Description:
Command:
reboot
Description:
Command:
kill
Description:
Command:
cd
394
379
[manju@localhost ~]$ ((b=2+2)); echo $b
4
Description:
Command:
login
Description:
Command:
lsof
Description:
Command:
lsusb
Description:
395
380
service network status
Command:
Description:
Command:
Description:
Command:
Description:
Report information about the users currently on the machine and their processes.
396
381
Command:
Description:
List every file and directory
Display the current directory. inside the /var/ directory
Command:
pwd
Description:
Displays CPU architecture information (such as number of CPUs, threads, cores, sockets, and
more).
Command:
lscpu
Description:
Command:
nproc
[manju@localhost ~]$
397
382
Description:
Command:
init 6
Description:
Command:
init 0
Description:
Command:
ls -lrt
Description:
Report information about storage devices such as hard disks, flash drives etc.
Command:
lsblk
398
383
[manju@localhost ~]$ a[0]="Alan"; a[1]="Albert"; echo ${a[1]}
Albert
Description:
Command:
echo $?
Description:
Command:
info
Description:
Command:
cal -y
Description:
399
384
service --status-all
Description:
Command:
date +%T
Description:
Tells when the user last logged on and off and from where.
Command:
last -1 username
Description:
Command:
ls -X
Description:
400
385
Command:
man pwd
Description:
Command:
pstree
Description:
Command:
reset
Description:
Command:
date -d fri
401
385
[manju@localhost ~]$ echo ${a+26}
26
Description:
Command:
du -a
Description:
Command:
acpi
Description:
Command:
cd ../..
Description:
Command:
cd -
402
387
Servlet
Description:
A little computer application that
Displays a list of shell built-in commands. extends the functionality of a
larger piece of server software
Command:
help
ISDN
(Integrated Services Digital Network)
Description:
A technique to send more data over
Lists your last logins.
current telephone lines
Command:
last yourusername
Command:
mkdir myfiles
FDDI
Description:
(Fiber Distributed Data Interface)
Remove the directory myfiles.
403
387
rmdir myfiles
Description:
Command:
passwd -d root1
DHCP
(Dynamic Host Configuration Protocol)
Description:
A protocol that allows a machine to receive
Switch to user "root1".
an IP address from a local network server
Command:
sudo su root1
Command:
logout
Intranet Internet
A more secure private A less secure
Description: network public network
404
389
Command:
useradd "root1"
Description:
Command:
passwd "root1"
Description:
Command:
!!
Description:
Command:
whoami
405
390
Description:
Command:
logname
Description:
Command:
uname
Description:
Command:
uname -v
Description:
Command:
uname -o
406
390
[manju@localhost ~]$ num=6+2*20; echo $num
6+2*20
[manju@localhost ~]$ declare -i num; num=6+2*20; echo $num
46
Description:
Command:
uname -m
Description:
Command:
uname --version
Description:
Command:
uname -r
Description:
Command:
407
390
uname -n
Description:
Command:
netstat -a
Description:
Command:
netstat -at
Description:
Command:
netstat -au
Description:
408
390
Command:
netstat -I
Description:
Command:
netstat -It
Description:
Command:
netstat -lu
Description:
Reveal all the information about the current user (user id, username, group id, group name etc.).
Command:
id
409
394
Description:
Reveal all the information about the user "root1" (user id, username, group id, group name etc.).
Python code:
Command:
x = 'a bowman'
id root1 print('{0:>{1}s}'.format(x, len(x)+4))
print('{0:_^{1}s}'.format(x, len(x)+4))
a bowman
Output
Description: __a bowman__
Command:
arch
Description:
Description:
Command:
410
395
Description:
Command:
# divmod(7,2) computes quotient and remainder of 7/2
yum install httpd print(divmod(7, 2))
# Output: (3, 1)
# quotient = 3
# remainder = 1
Description:
Command:
x = 12
if x == 28:
# Output:
Description: x is a multiple of 2
Command:
411
395
apt update httpd
for x in range(3):
Description:
x = x*2
uninstall apache (CentOS). print(x)
# Output:
Command:
0
yum remove httpd 2
4
Description:
Command: x = "https://en.wikipedia.org/wiki/Isaac_Newton"
Description:
Command:
date --help
print("1988".isnumeric())
# Output: True
Description:
412
395
Command: print('''{name} laid the foundations of {subject} and put forward the {law} in
1687.'''.format(subject='Calculus', law='law of gravitation', name='Sir Isaac
ss -tup Newton'))
# Output:
Sir Isaac Newton laid the foundations of Calculus and put forward the law of
gravitation in 1687.
Description:
Command:
ss -tupl
name = 'Albert'
Description: if 'b' in name:
print("Found 'b' in name")
Display all active UNIX listening ports.
if name == 'Albert':
print("Albert Einstein")
Command: else:
print("Some other name")
netstat -lx else:
print("A name without 'b'")
# Output:
Found 'b' in name
Description:
Albert Einstein
Display all the active interfaces details.
Command:
print(x, y)
myfunc(11) # Output: 11 14
413
395
Description:
Command:
Description:
Tells you how many lines, words, and characters there are in a file (1.txt).
Command:
# prints the widely used UNIX timestamp
print(int(time.time()))
# Output: 1658163944
Description:
Command:
gzip 1.txt
414
399
Description:
Command:
# prints the path of os module
gunzip 1.txt import os
print(os)
# Output:
<module 'os' from 'C:\\Users\\Manju\\Anaconda3\\lib\\os.py'>
Description:
import json
Description:
Display calendar.
Command:
import logging
ncal
x = logging.getLogger('alan')
y = logging.getLogger('mary')
Description: z = logging.getLogger('alan')
Command:
415
399
a = 'x y'
rm 1.txt print(a.split())
# Output: ['x', 'y']
print(a.split(' '))
# Output: ['x', '', 'y']
Description:
Command:
mv 1.txt 0.txt
Description:
Description:
Description:
416
401
def divide(divisor, dividend):
Description:
Command:
from pprint import pprint
tail -n N 1.txt pprint('hi')
# Output: hi
Description:
Description:
Command:
wc -m 1.txt
417
402
Description:
Command: print(u'john'.translate({ord('j'):None,ord('n'):u'cv'}))
print(u'albert'.translate({ord('a'):None,ord('r'):u'cv'}))
# Output: lbecvt
Description:
Print information about usb ports, graphics cards, network adapters etc.
Command:
import ast
lspci print(ast.literal_eval('54')) # prints 54
print(ast.literal_eval('[54,96]')) # prints [54, 96]
Description:
for i in range(5):
# Output:
Command:
+0.00
less 1.txt +1.00
+2.00
+3.00
+4.00
Description:
Command:
cal -3
418
402
Description:
Compare the contents of three files (1.txt, 2.txt, 3.txt) line by line.
print(sys.byteorder)
# Output: little
Description:
Command:
Description:
Description:
Prints the CRC checksum and byte count for the file "myfiles.txt".
Command:
419
402
cksum myfiles.txt
Description:
x =[2,4,-6,-9,10,11,12]
Command: if all(i>0 for i in x):
Description:
Append contents of files (1.txt, 2.txt, 3.txt) into one file (0.txt).
x =[2,4,6,9,10,11,12]
Command:
if any(i<0 for i in x):
sed r 1.txt 2.txt 3.txt > 0.txt print('Some are negative')
else:
print('None are negative')
# Output: None are negative
Description:
Append contents of files (1.txt, 2.txt, 3.txt) into one file (0.txt).
Command:
Description:
Append contents of files (1.txt, 2.txt, 3.txt) into one file (0.txt).
420
405
Command:
Shortcuts:
Description:
Writes contents of a file (0.txt) to output, and prepends each line with line number.
Command:
nl 0.txt
Description:
Command:
mkdir test
cd test
pwd
touch test1.txt
421
406
Description:
Gather information about hardware components such as CPU, disks, memory, USB controllers
etc.
Command:
sudo lshw
Description:
Command:
sudo fdisk -l
Description:
Displays the line (good morning) in which the string (good) is found in the file (1.txt).
Command:
Description:
Append contents of files (1.txt, 2.txt, 3.txt) into one file (0.txt) using for loop.
422
407
Command:
Description:
Search for files (test.txt, test1.txt, test2.txt, test.php, test.html) in a directory as well as its sub-
directories.
Command:
find test*
Description:
Command:
stat 1.txt
###
| Command | Description |
|: | : |
| vi | Open vi editor |
| i | Go to Insert mode |
| | |
| a =20; b =64; | |
| print (a + b); | |
| Hit Escape to return to Normal mode. |
| :w hello.py | Save text |
| :q | Quit |
| python hello.py |Print the output:84 |
Description:
423
408
Download the file (file.txt) from url "http: //website.com/files/file.txt".
Command:
wget http://website.com/files/file.txt
Description:
Command:
hostid
Description:
Command:
file myfiles.txt
Description:
Command:
424
409
Description:
Command:
Description:
Command:
hostname -i
Description:
Command:
Description:
425
410
Command:
whatis cal
###
| Command | Description |
|: | : |
| vi | Open vi editor |
| i | Go to Insert mode |
| Type some text. | |
| Hit Escape to return to Normal mode. |
| :w test.txt | Save text |
| :q | Quit |
| :q! |Quit without saving |
###
| Command | Description |
|: | : |
| vi | Open vi editor |
| i | Go to Insert mode |
| $name = "Paul"; | |
| print "$name"; | |
| Hit Escape to return to Normal mode. |
| :w hello.pl | Save text |
| :q | Quit |
| perl hello.pl |Print the output: Paul |
###
| Command | Description |
|: | : |
| vi | Open vi editor |
| i | Go to Insert mode |
| echo "What is your name?" | |
| read PERSON | |
| echo "Hello, $PERSON" | |
| Hit Escape to return to Normal mode. |
| :w hello.sh | Save text |
| :q | Quit |
| sh hello.sh | Output: |
| | What is your name? |
| | If you enter: Zara Ali |
| | Hello, Zara Ali |
Description:
Check the network connectivity between host (your connection) and server (Google server).
426
411
The first ever Linux kernel just occupied only 65 KB.
Command:
ping google.com
Description:
Command:
whereis cal
427
[manju@localhost ~]$ awk '{print $0}' file.txt
Hello World All of the 500 fastest
[manju@localhost ~]$ awk '{print $1}' file.txt supercomputers run
Hello
Linux
[manju@localhost ~]$ awk '{print $2}' file.txt
World
echo $$ echo $!
import os
Execution of the linux
find -type f os.system('ls')
command "ls" using the python
# Find all the files program to list all the files and
import subprocess
directories in the current
subprocess.call ('ls')
find -type d directory
# Find all the directories
428
Command:
last reboot
Description:
Command:
dmesg
Description:
Displays the messages from the kernel ring buffer (a data structure that records
messages related to the operation of the kernel)
cat /proc/cpuinfo
Description:
429
i=1; while [[ $i -le 5 ]] ; do echo "$i";(( i = i+1 )); done
Command: Output:
1
2
cat /proc/meminfo
3
4
5
Description:
lspci -tv
Description:
lsusb -tv
430
[manju@localhost ~]$ let c=8-6; echo "8 - 6 =" $c
8 - 6 = 2
Command:
free -h
Description:
Display free and used memory (-h for human readable, -m for MB, -g for GB)
mpstat 1
Description:
431
Display virtual memory statistics
iostat 1
Description:
Command:
watch df -h
Description:
Command:
[manju@localhost ~]$ cat 1.txt
Alan
ps -ef Albert
Hawking
John
[manju@localhost ~]$ file='1.txt'; while read line; do echo $line; done < $file
Alan
Description: Albert
Hawking
John
432
Display all the currently running processes on the system
[manju@localhost ~]$ filename=12.txt; if [ -f "$filename" ]; then echo "File exists" ; else echo "File does not exist"; fi
File does not exist
Command:
ip a
Description:
dig wikipedia.org
Description:
Command:
host wikipedia.org
433
Display the IP address details of the specified domain (wikipedia.org)
Command:
netstat -nutlp
Description:
Display listening Transmission Control Protocol (TCP) and the User Datagram
Protocol (UDP) ports and corresponding programs
Command:
rpm -qa
Description:
Command:
Description:
Command:
434
yum info httpd
Description:
Command:
du -ah
Description:
Display disk usage for all files and directories in human readable format
du -sh
Description:
435
cd /etc
Description:
Command:
ps -A
Description:
List the status of all the processes along with process id and PID
Command:
#include <stdio.h>
int main()
{
printf("Hello world\n"); Hello.c
return 0;
}
gcc Hello.c
436
Description:
Command:
#include <iostream>
int main()
{
std::cout << "Hello world!"; Hello.cpp
return 0;
}
g++ Hello.cpp
Description:
Command:
tty
Description:
437
Command:
javac MyClass.java
Description:
Compile the Java program saved in MyClass.java file using javac compiler
Command:
od -b myfiles.txt
Description:
Command:
od -c myfiles.txt
438
Description:
od -An -c myfiles.txt
Description:
Displays the contents of myfiles.txt file in character format but with no offset
information
Command:
Description:
If the file myfiles.txt has 123 lines, the csplit command would create four files: the xx00 file
would contain lines 1−12, the xx01 file would contain lines 13−61, the xx02 file would contain
439
md5sum myfiles.txt
Description:
Prints a 32-character (128-bit) checksum of myfiles.txt file using the MD5 algorithm
Command:
more myfiles.txt
Description:
Command:
sha1sum myfiles.txt
Description:
Command:
440
shred myfiles.txt
Description:
Overwrites the myfiles.txt file repeatedly − in order to make it harder for even very
expensive hardware probing to recover the data
Command:
cat myfile.txt
01. Einstein
02. Newton
03. Maxwell
04. Tesla
05. Edison
tac myfile.txt
05. Edison
04. Tesla
03. Maxwell
02. Newton
01. Einstein
Description:
441
Command:
uniq myfiles.txt
Description:
Command:
chkconfig --list
Description:
Displays a list of system services and whether they are started (on) or stopped
(off) in run levels 0−6
Command:
halt -p
Command:
Description:
xdg-open myfiles.txt
442
Command:
lastlog
Description:
Prints the details of the last login (login-name, port and last login time)
Description:
cat /proc/4504/environ
lastlog -u manju
Description:
443
Command:
cat /etc/passwd
# Print all the files that were accessed within the last 8 days
find . -type f -atime -8 -print
# Print all the files that are having access time exactly 8-days old
find . -type f -atime 8 -print
more /etc/passwd
# Print all the files that have an access time older than 8 days
find . -type f -atime +8 -print
# Print all the files that have an access time older than 8 minutes
less /etc/passwd
find . -type f -amin +8 -print
Description:
Command:
tail -5 /etc/passwd
head -5 /etc/passwd
444
Description:
Command:
Description:
Description:
List the password and its related details for a user (manju)
445
Command:
chage -M 10 manju
Description:
Command:
Description:
Command:
chage -I 10 manju
Description:
446
Command:
ftp 192.168.42.77
Description:
ODBC
(Open Database Connectivity)
Command:
Description:
Lists all the peers connected at various interfaces along with their MAC
dnsdomainname
447
Display the system's DNS domain name
Command:
domainname
Description:
Command:
Output: SGVsbG8gV29ybGQhCg==
Description:
Command:
Description:
448
Decode (SGVsbG8gV29ybGQhCg==) to text (Hello World!)
Command:
fc-cache -f -v
Description:
Command: Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
cat 1.txt 15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Einstein
Newton [manju@localhost ~]$ if grep -q 'cal' ~/.bash_history; then echo "You seem to
Albert have typed 'cal' before."; fi
Description:
449
cat phy.txt
fmt -w 1 phy.txt
Albert
Einstein
was
a
German-born
theoretical
physicist,
widely
acknowledged
to
be
one
of
the
greatest
physicists
of
all
time.
Einstein
is
known
for
developing
450
the
theory
of [manju@localhost ~]$ echo Albert
relativity, Albert
but
he [manju@localhost ~]$ !e
also echo Albert
made Albert
important
[manju@localhost ~]$ !echo
contributions
echo Albert
to
Albert
the
development
[manju@localhost ~]$ !echo Einstein
of echo Albert Einstein
the Albert Einstein
theory
of
quantum
mechanics.
cat phy.txt
fold -w 20 phy.txt
451
a German-born theor
etical physicist, wi
dely acknowledged to find . -type f -size +10k
# Display files having size > 10 kilobytes
be one of the great
est physicists of al
find . -type f -size -10k
l time. Einstein is # Display files having size < 10 kilobytes
known for developing
the theory of relat find . -type f -size 10k
# Display files having size = 10 kilobytes
ivity, but he also m
ade important contri
butions to the devel
opment of the theory
of quantum mechanic
s.
Command:
traceroute google.com
Description:
Prints the route that a packet takes to reach the Google (172.217.26.206) host
from the local machine
Command:
cat 1.txt
452
Einstein
Newton
Albert [manju@localhost ~]$ echo {2,4}
2 4
gzip 1.txt [manju@localhost ~]$ echo {2,4}{2,4}
22 24 42 44
zcat 1.txt.gz [manju@localhost ~]$ echo {2,4}{2,4}{2,4}
222 224 242 244 422 424 442 444
Einstein
Newton
Albert
Description:
Command:
Description:
du -cks *
453
Command:
ss | less
Description:
Command:
echo "Albert" > 1.txt ; cp 1.txt 2.txt ; cp 1.txt 3.txt;
ss -aA tcp
[manju@localhost ~]$ x="Albert Einstein"; echo ${x/Albert/Elsa}
Elsa Einstein
Description:
ss -aA udp
[manju@localhost ~]$ x=abcdefghijklmnopqrstuvwxyz; echo ${x:(-1)}
z
[manju@localhost ~]$ x=abcdefghijklmnopqrstuvwxyz; echo ${x:(-2):2}
yz
Description:
454
Command:
ss -lnt
Description:
netstat -tnp
Command:
ss -s
Description:
455
Command:
ss -tl6
Description:
Description:
Command:
Description:
456
Command:
pmap 3244
Description:
Command:
Description:
Command:
apropos editor
Description:
Display information about the editing programs that are available on a system
[manju@localhost ~]$ echo "<a href=\"$img\" ><img src=\"thumbs/$img\" title=\"$img\" /></a>" >> 1.html
[manju@localhost ~]$ cat 1.html
<a href="" ><img src="thumbs/" title="" /></a>
457
Command:
apropos pstree
Description:
Provide information about the pstree command (which displays the names of the
processes currently on the system in the form of a tree diagram)
head -10 myfile1.txt The apropos command is useful when you know what you want to do,
# Display the first 10 lines of the file myfile1.txt but you have no idea what command you should be using to do it. If you
were wondering how to locate files, for example, the commands
apropos find
tail -10 myfile1.txt
apropos locate
# Display the last 10 lines of the file myfile1.txt would have a lot of suggestions to offer.
ls; who
# Execute ls command first and then who command
Output: passwd
basename /usr/local/apache2/conf/httpd.conf
458
Output: httpd.conf
echo a b c d e f| xargs
Output: a b c d e f
echo a b c d e f| xargs -n 3
a b c
d e f
Command:
env
Description:
Command:
459
printenv HOME
Description:
cat score.txt
Albert-30
[manju@localhost ~]$ printf "2 + 2 = %d" 4
John-50
2 + 2 = 4
William-80
Stephen-20
[manju@localhost ~]$ printf "William %f" 2
Justin-40
William 2.000000
30
50
80
20
40
460
cat 1.txt
cat 2.txt
Computer Program
cat 2.txt
Computer Program
461
Command:
rev 1.txt
Description:
sort 3.txt
11
22 sorts numeric values in 3.txt file and displays sorted output
33
55
77
462
[manju@localhost ~]$ if ping -c 1 google.com; then echo " It
looks that your internet connection is operational"; fi
cat 5.txt
[manju@localhost ~]$ name="Albert Einstein"; echo ${name:7:9}
Einstein
zz
zz
yy
yy
yy
xx
uniq 5.txt
463
cat 6.txt awk -F ':' '{print $1}' /etc/shadow|uniq -u
nl 6.txt
Command:
ls -l *.txt
Description:
The thing with Linux is that the developers themselves are actually customers too: that has
always been an important part of Linux.
Linus Torvalds
464
Linux Unix
Source code is accessible to the general public Source code is not accessible to anyone
Uses Graphical User Interface with an optional Uses Command Line Interface
Command Line Interface
Command:
echo $SHELL
Description:
Command:
echo $0
Description:
Display the name of the currently running process ($0 is the name of the running
process). If you use it inside of a shell then it will return the name of the shell. If you
use it inside of a script, it will return the name of the script
465
Command:
echo *
Description:
Command:
Description:
Print the process ID of the current shell ($$ is the process ID of the current shell)
Command:
466
cat /etc/shells
Description:
List shells
Command:
echo m*
Description:
Display the files in the current folder that start with the letter "m".
Command:
last
Description:
List last logins of users and what happened such as "shutdown" or "crash" etc.
Command:
echo ~
Command:
Description:
467
bzip2 -k phy.txt
Description:
phy.txt → phy.txt.bz2
Command:
bzip2 -d phy.txt.bz2
Description:
phy.txt.bz2 → phy.txt
Command:
bzcat phy.txt.bz2
468
Description:
Command:
bunzip2 phy.txt.bz2
Description:
Command:
crontab -l
Description:
469
cp /dev/null phy.txt
Description:
Description:
470
nohup ping google.com > log.txt &
Description:
pgrep -a ping
Output:
kill 3858
pgrep -a ping
Output:
Command:
ls -la /home
471
Description:
Command:
sudo shutdown 2
Description:
Command:
shutdown -c
Description:
Command:
pr 36.txt
472
Description:
Display the contents of the file (36.txt) one page after the other
Command:
stty -a
Description:
Data in Use
Display all current terminal settings
Data that is currently being
processed by a computer
Command:
ls -1
Description:
Heterogeneous Network: A network
consisting of systems with different
List files one per line
architectures
473
yes John
Description:
Command:
vdir
Description:
List files and directories in the current directory (one per line) with details
Command:
who -b
Description:
474
nano phy.txt
vim phy.txt
Memory
Software
The internal storage
location where data and
Hardware Network
w --ip-addr
# Displays information regarding the users currently on the machine, login time, IDLE time,
TTY and CPU time
Output:
w –short
# Omits CPU time and login information
Output:
Command:
findmnt
Description:
Command:
476
ip addr show
Description:
Command:
netstat -pnltu
Durability:
Description:
Regardless of whether the database fails
List active (listening) ports
or not, each database transaction will be
preserved by backups or other methods
Command:
journalctl
Description:
477
sudo systemctl status network
Description:
Command:
Go program:
package main
sudo systemctl start network
import "fmt"
func main() {
lang:= []string{"Java", "Go", "Python"}
for x, y:= range lang {
Description: fmt.Println(x, y)
}
Start the network service }
Output:
0 Java
Command: 1 Go
2 Python
Description:
Command:
478
sestatus -b
Description:
Command:
getenforce
Description:
Security-Enhanced Linux (SELinux) is a security architecture for Linux systems that allows
administrators to have more control over who can access the system
setenforce 0
479
getenforce
Output:
Permissive
setenforce 1
getenforce
Output:
Enforcing
480
Intent-based networking (IBN): An emerging technological
approach that improves network operations and uptime by
combining intelligence, analytics and automation
Command:
sestatus
Description:
Display the current status of the SELinux that is running on your system
Command:
ps -aef
Industrial internet of things (IIoT):
Command:
sar
Data Deduplication:
481
Display System Activity Report
Fail-safe
Command:
In the case of a failure, a system that automatically switches to a safer
operational mode
ulimit
Description:
Output:
Unlimited The current user can consume all the resources the current system supports
Hard resource limit: The physical limit that the user can reach.
Soft resource limit: The limit that is manageable by the user (its value can go up to the
hard limit)
Consistency checker:
Command:
A software tool for checking the accuracy and reliability of
demands in design specifications
482
ulimit -a
Description:
Description:
Description:
483
Crash recovery
Command:
Description:
Command:
ulimit -v
Command:
ulimit -n
Description:
484
[manju@localhost ~]$ echo "alanBalbertBjohnBmary" | xargs -d B
alan albert john mary
Command:
[manju@localhost ~]$ echo "alanBalbertBjohnBmary" | xargs -d B -n 2
alan albert
man limits.conf
john mary
Description:
Command:
sar -V
Description:
Command:
[manju@localhost ~]$ echo 987654 | tr '0-9' '9876543210'
012345 # Encrypted
Description:
485
Command:
Description:
Report about network interface, network speed, IPV4, TCPV4, ICMPV4 network traffic and errors
Description:
Report details about the process, kernel thread, i-node, and the file tables
Description:
486
Command:
sar -b 1 3
Description:
Report details about I/O operations like transaction per second, read per second, write per second
Command:
Fragmentation
Description:
The methodology of breaking down an
Display the status of the firewalld IP datagram into smaller bits to
match the needs of a specific physical
network
Command:
Description:
487
firewalld is a firewall management tool for Linux operating systems
ls ??[rgi]*
firewall-config
Description:
firewall-cmd
Command:
firewall-cmd --list-all-zones
Description:
Interpreter Compiler
Translates the program line Scans the whole program and
Command: by line into machine code converts it into machine code
488
firewall-cmd --get-default-zone
Description:
Command:
firewall-cmd --list-services
Description:
Command:
firewall-cmd --list-ports
Description:
Command:
489
firewall-cmd --zone=work --list-services
Description:
Command:
Description:
Provides information about the route that Internet traffic takes between the local
system and a remote host (google.com)
Command:
Description:
490
Samba is client/server technology that Iterative incremental software development: The
Description:
Command:
Description:
Design of experiments:
491
unzip q.zip
Description:
zipcloak q.zip
-----------------------------------------------------------------------------
# zipcloak prompts you for a password, and then ask you to confirm it:
Enter password:
Verify password:
----------------------------------------------------------------------------
unzip q.zip
# When you try to unzip the q.zip file, it prompts you for the password before
allowing you to extract the file (q.txt) it contains
492
Command:
zgrep -l "Einstein" *
Description:
Display the names of the files with the word (Einstein) present in it
Command:
Description:
Split q.zip file to create a sequence of zipfiles (q1.zip, q2.zip…..) − each no larger
than 1048576 bytes (one megabyte)
You could concatenate (q1.zip, q2.zip…..) into a new file, w.zip, with the
command:
493
Command:
mtr google.com
Description:
Test the route and connection quality of traffic to the destination host google.com
route
Description:
Command:
494
Description:
Description:
ss -ta
Description:
Amelioration pattern:
Command:
A design pattern that explains how to get from
a poor to a good solution
495
ss -to
Description:
Command:
type -a alias
Description:
# Difference between %Y and %y is %Y will print 4 digits while %y will print the last 2 digits of the year.
# Difference between %B and %b is, %B will print full month name while %b will print abbreviated month
name.
496
echo "We are in the month = $(date +%B)"
# Difference between %A and %a is, %A will print full Weekday name while %a will print abbreviated weekday
name.
497
echo "tomorrow = $(date -d "tomorrow")"
# Find what is the date and time before 10 days from now.
echo "Before 10 days = $(date -d "tomorrow -10 days")"
Command:
ls -lai /
Description:
Command:
sudo du --inode /
Description:
498
Get the total number of inodes in the root directory
Command:
Description:
Get the list of all clients connected to HTTP (Port 80) or HTTPS (Port 443)
Command:
Description:
Command:
Description:
499
Install PuTTy on CentOS
Command:
• cat /etc/*release
sudo watch netstat -tulpn
• cat /etc/os-release
Description:
Command:
Description:
500
Capability Maturity Model:
Description:
An approach for improving and
Command:
Synchronize-and-stabilize
Description:
Command:
ss -ua
Description:
Shotgun debugging: The methodology
of detecting and eliminating errors from a
List all UDP Connections computer software, hardware, or software
problem by attempting multiple different
solutions at the same time in the hopes of
Command: finding one that works
501
ss -lu
Description:
Description:
Command:
ss -4
Description:
502
wc -l /home/fi*
# List the files in '/home' directory that start with 'fi' and then display the number of lines in each file
Command:
ss -6
− Dennis Ritchie
Command:
Description:
[manju@localhost ~]$ ls -l | grep '^-'| awk 'BEGIN {sum=0} {sum = sum + $5} END {print sum}'
26591723
Print the sum of bytes (size of the file) of all files in a directory
503
Command:
Description:
Command:
history -c
Description:
Command:
ping -c 5 www.google.com
Description:
504
# count number of lines in each .txt file
ls *.txt | xargs wc -l
ls *.txt | xargs wc -w
ls *.txt | xargs wc -c
ls *.txt | xargs wc
Command:
lslogins –u
Description:
505
Command:
Description:
List all loaded services on your system (whether active; running, exited or failed)
Command:
systemctl --type=service
Description:
List all loaded services on your system (whether active; running, exited or failed)
Command:
506
Description:
Command:
Description:
Command:
Description:
List all running services (i.e., all loaded and actively running services)
[manju@localhost ~]$ ls ab@(.txt|.cpp)
ab.cpp ab.txt
[manju@localhost ~]$ ls ab+(.txt|.pdf)
Command:
ab.pdf ab.txt
[manju@localhost ~]$ ls ab*(.txt|.cpp)
ab.cpp ab.txt
[manju@localhost ~]$ ls ab!(.pdf|.txt)
abc.cpp ab.cpp abc.txt
507
systemctl --type=service --state=running
Description:
List all running services (i.e., all loaded and actively running services)
Command:
cat /etc/resolv.conf
Description:
508
[manju@localhost ~]$ a="Albert"; echo ${#a}
Command:
6
less /etc/resolv.conf
Description:
findmnt -l
Description:
Description:
509
Command:
uptime –s
Description:
Command:
uptime –h
Description:
Command:
Description:
510
Command:
crontab -r
Description:
ADD=$(( 1 + 2 ))
echo $ADD
3
MUL=$(( $ADD * 5 ))
echo $MUL
15
SUB=$(( $MUL - 5 ))
echo $SUB
10
DIV=$(( $SUB / 2 ))
echo $DIV
5
MOD=$(( $DIV % 2 ))
echo $MOD
511
Command:
Description:
echo '3+5' | bc
8
(a + b) = 8
Command:
factor 10
Description:
512
Command:
ps -e
Description:
Description:
ps -fU manju
ifconfig | cut -c-10 | tr -d ' ' | tr -s '\n'
513
Display a user's processes by user name (manju)
Command:
ps -fu 1000
Description:
Command:
ps -U root -u root
Description:
Display every process running with root user privileges (real and effective ID)
514
Command:
locale
Description:
Command:
locale -a
System Modeling: A methodology for
describing, displaying, evaluating and
changing a system's architecture
Description:
515
Display a list of all available locales
cat score.txt
Justin-40
JUSTIN-40
JUSTIN-40
cat domainnames.txt
516
cat domainnames.txt
www.google.....com
www.fb.com
www.mactech.Com
My UID is 0
My
UID
is
0
myw3schools.com:=>Linux-Books,Src,Tutorials
Command:
517
!sud
Description:
!sudo
[manju@localhost ~]$ cat /proc/cpuinfo | sed -n 5p
model name : Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Command:
Description:
518
Generate a compact list of all Linux user accounts on the system
Description:
Command:
Description:
[manju@localhost ~]$ x=0; until [ $x -gt 2 ]; do echo $x; x=`expr $x + 1`; done
0
1
2
Command:
519
find . -type f -perm 0777 -print
Description:
Command:
Description:
Command:
Description:
Command:
520
find / -perm /u=r
Description:
manju 7859 0.0 0.0 112648 960 pts/0 R+ 05:32 0:00 grep --color=auto nginx
manju 7864 0.0 0.0 112648 956 pts/0 S+ 05:33 0:00 grep --color=auto apache
521
find . -type f -name "phy.txt" -exec rm -f {} \;
Description:
Description:
522
To find and remove multiple .mp3 files
Command:
Description:
Command:
Description:
Command:
523
find / -mtime 50
Description:
Command:
find / -atime 50
find . -type f -name "*.txt" -print0 | xargs -0 rm -f
# List of all the .txt files and remove them
Description:
Command:
Description:
524
Find Changed Files in Last 1 Hour
Command:
Description:
Command:
Description:
Command:
type cat
Description:
Command: Identifies whether the "cat" command is a shell built-in command, subroutine, alias, or keyword.
525
find / -size 50M
Description:
Command:
Command:
Description:
Find all .mp3 files with more than 10MB and delete them
[manju@localhost ~]$ for x in `seq 5 -2 1`; do echo -en "${x} ..."; done; echo "Albert"
5 ...3 ...1 ...Albert
526
Command:
cat /proc/sys/fs/file-max
Description:
Command:
[manju@localhost ~]$ echo *
1.txt 1.zip ab.txt AB.txt bc.txt BC.txt cd.txt CD.txt Desktop Documents
Downloads io.txt IO.txt log Music Pictures Public Templates test.txt Videos
[manju@localhost ~]$ echo '*'
*
ulimit -Hn
Description:
Command:
ulimit -Sn
Description:
527
Command:
Description:
timedatectl list-timezones
Description:
Command:
528
[manju@localhost ~]$ ps -eaf | grep -w apache
manju 4033 3913 0 01:15 pts/1 00:00:00 grep --color=auto -w apache
Description:
Find the local timezone according to your location List all of the Apache
web server processes
Command:
Description:
[manju@localhost ~]$ echo Albert Einstein was a Jewish\; German-born theoretical physicist.
swapon --summary
Command:
529
[manju@localhost ~]$ ls -ld /etc/rc{0,1,2,3,4,5,6}.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc0.d -> rc.d/rc0.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc1.d -> rc.d/rc1.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc2.d -> rc.d/rc2.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc3.d -> rc.d/rc3.d
cat /proc/swaps
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc4.d -> rc.d/rc4.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc5.d -> rc.d/rc5.d
lrwxrwxrwx. 1 root root 10 May 18 20:54 /etc/rc6.d -> rc.d/rc6.d
Description:
Listing of /etc/rc*.d
script history_log.txt
exit
dir -shl
Description:
530
"Don't write better error
messages, write code that
List files and their allocated sizes in blocks doesn't need them."
– Jason C. McDonald
Command:
less /proc/sys/dev/cdrom/info
Description:
cat date.txt
531
a=$(pwd)
echo "Current working directory is : $a"
/home/manju
Command:
echo *.jpeg
Description:
532
l
i
n
u
x
Command:
Description:
Output the files with respect of the user (root) owned files in the current directory
strace pwd
Description:
533
Command:
top -u manju
Description:
echo ${variable:a:b}
a → Start position
b → Length
Albert
ls -d ?[ab]*
# List files where second letter is a or b
534
Command: Workflow management
Description:
Datasheet
Find Out Linux Kernel Version
uname -a
Command:
cat /proc/version
Description:
Display some of your system information including the Linux kernel version
535
Command:
Description:
Functional Dependency
Displays the PIDs of processes currently accessing your current working directory
Dirty read:
Command:
commits the modification, transaction B reads the updated row
536
fuser -v -m .bashrc
Description:
Command:
Description:
Displays all the possible signals that can be used with the fuser tool
Command:
Description:
Sends the HUP signal to all processes that have your /boot directory open
537
Command:
ls -al
Description:
List all the files with the file permissions, the number of links to that file, the owner of the file, the group of the
file, the file size in bytes, the file's last modified datetime and the file name
Command:
538
Command:
Description:
Execute command "ls -al" and print the result to the standard output
Command:
Description:
Command:
Description:
539
Command:
Description:
Command:
Description:
Find all files in the current directory with .sh and .txt file extensions
Command:
Description:
Find all files in the current directory with .sh, .c and .txt file extensions
540
Name of the shell Program name Symbol
Bourne Shell sh $
Korn Shell ksh $
C Shell csh %
LAN WAN
Small computer network that covers a building or a campus Wider computer network that covers a city or the entire globe
Syntax errors [manju@localhost ~]$ for (( i=0; i<=2; i=i+1 )); do echo "Welcome $i times"; done
Welcome 0 times
Logical errors
Welcome 1 times
Run-time errors Welcome 2 times
541
[manju@localhost ~]$ a=1; b=2; echo $((a+b))
Syntax errors:
3
c = a+b;
If the above statement is typed without the semicolon at the end, then there will be a syntax error because of
a missing semicolon.
Logical errors: A Mistake in a program's source code that result in incorrect or unexpected behavior. It is a
type of runtime error that may simply produce the wrong output or may cause a program to crash while
running.
Run-time errors → Device errors, improper sequencing of constructs, errors in system software, Keypunch
errors, incorrect data input.
cat /etc/passwd|wc -l
# Count local accounts
Software
542
414
Recursion is the technique that defines a function in terms of itself. That is, a function which
performs a particular task is repeatedly calling itself. The best example of recursively defined
function is computing the factorial of a given number.
cout << "Factorial of " << n << " = " << factorial(n);
return 0;
} [manju@localhost ~]$ echo "5 * 2.77" | bc
13.85
{ 24.0
return 1; 16
Since: 6 > 1
415
543
720 is returned to main() function by factorial(int n) to print
Factorial of 6 = 720
Description:
Command:
ls /bin
Description:
List the files in the bin directory and the etc directory.
Command:
ls /bin /etc
Description:
Command:
mv test.txt ./newrepo
416
544
Description:
Command:
Git Commands
Description:
Command:
git log
Description:
Command:
Description:
Command:
417
545
git log --oneline
Description:
Command:
Description:
Command:
git help
Description:
Command:
git version
Description:
418
546
Command:
Description:
Check status.
Command:
git status
Description:
Command:
git branch -a
Description:
Command:
419
547
Description:
Command:
touch test.txt
git init
git add test.txt
git commit -m "first commit"
git remote add origin [email protected]:myw3schools/colors.git
git push -u origin main
548
Introduction
You might have an algorithm for getting from office to home, for making a chunk of code that calculates
the terms of the Fibonacci sequence, or for finding what you're looking for in a retail store. Algorithms
are the building blocks of computer programs or sequence of unambiguous instructions (the term
'unambiguous' indicates that there is no room for subjective interpretation) that tells how the problem
could be addressed and solved − which is definitely overblown in their importance like road maps for
accomplishing a given, well-defined automated reasoning task − which always have a clear stopping
point.
Long division and column addition are examples that everyone is familiar with − even a simple function
for adding two numbers is implementation of a particular algorithm. Online grammar checking uses
algorithms. Financial computations use algorithms. Robotic field uses algorithms for controlling their
robot using algorithms. An encryption algorithm transforms data according to specified actions to
protect it. A search engine like Google uses search engine algorithms (such as, takes search strings of
keywords as input, searches its associated database for relevant web pages, and returns results). In fact, it
is difficult to think of a task performed by your computer that does not use computer rules that are a lot
like a recipes (called algorithms).
The use of computer algorithms (step-by-step techniques used for Problem-solving) plays an essential
role in space search programs. Scientists have to use enormous calculations, and they are managed by
high-end supercomputers, which are enriched with detailed sets of instructions that computers follow to
arrive at an answer. Algorithms have applications in many different disciplines from science to math to
physics and, of course, computing − and provide us the most ideal option of accomplishing a task. Here
is some importance of algorithms in computer programming.
• To improve the effectiveness of a computer program: An algorithm (procedure or formula for solving a
problem, based on conducting a sequence of specified actions) can be used to improve the speed at which a
program executes a problem and has the potential of reducing the time that a program takes to solve a
problem.
• Proper usage of resources: The right selection of an algorithm will ensure that a program
consumes the least amount of memory. Apart from memory, the algorithm can determine the
amount of processing power that is needed by a program.
549
The algorithm for a child's morning routine could be the following:
Smet's Rule: A methodology for
generating joint belief functions
Step 1: Wake up and turn off alarm from conditional belief functions
Step 5: Go to school
The algorithm to add two numbers entered by user would look something like this:
Step 1: Start
Unique Name Assumption
Step 2: Declare variables num1, num2 and sum
Step 3: Read values num1 and num2
Step 4: Add num1 and num2 and assign the result to sum
Different names will always
sum ← num1 + num2
imply different elements in the
model
Step 5: Display sum
Step 6: Stop
Two of these algorithms accomplish exactly the same goal, but each algorithm does it in completely
different way to achieve the required output or to accomplish our task. In computer programming, there are
often many different ways – algorithms (any well-defined computational procedure that takes some value,
or set of values, as input and produces some value, or set of values as output) − to accomplish any given
task. Each algorithm has credits and demerits in different situations. If you have a million integer values
between -2147483648 and +2147483647 and you need to sort them, the bin sort is the accurate algorithm
to use. If you have a million book titles, the quick sort algorithm might be the best choice. By knowing the
toughness and weaknesses of the different algorithms, you pick the best one to accomplish a specific task
or to solve a specific problem.
One of the most important aspects of an algorithm is how fast it can manipulate data in various ways,
such as inserting a new data item, searching for a particular item or sorting an item. It is often easy to come
up with a list of rules to follow in order to solve a problem, but if the algorithm is too slow, it's back to the
550
drawing board. Efficiency of an algorithm depends on its design and implementation. Since every
procedure or formula for solving a problem based on conducting a sequence of specified actions − uses
computer resources to run − execution time and internal memory usage are important considerations to
analyze an algorithm.
Algorithms are the heart of computer science (usually means a procedure or basically instance of logic
written in software that solves a recurrent problem of finding an item with specific properties among
collection of items or transforming data according to specified actions to protect it), and the subject has
countless practical applications as well as intellectual depth that is widely used throughout all areas of
information technology including solving a mathematical problem (as of finding the greatest common
divisor ) in a finite number of steps that often involves repetition of an operation. The word algorithm − a
mathematical concept whose roots date back to 600 AD with invention of the decimal system − derives
from the name of the ninth century Persian mathematician and geographer, Mohammed ibn-Musa al-
Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. On the
other hand, it turns out algorithms (widely recognized as the foundation of modern computer coding) have
a long and distinguished history stretching back as far as the Babylonians.
Although there is some available body of facts or information about early multiplication algorithms in
Egypt (around 1700-2000 BC) the oldest algorithm is widely recognized to be valid or correct to have
been found on a set of Babylonian clay tablets that date to around 1600 - 1800 BC. Their exact
significance only came to be revealed or exposed around 1972 when an American computer scientist,
mathematician, and professor emeritus at Stanford University Donald E. Knuth published the first
English translations of various Babylonian cuneiform mathematicaltablets.
Here are some short extracts from his 1972 manuscript that explain these early algorithms:-
"The calculations described in Babylonian tablets are not merely the solutions to specific
individualproblems; they are actually general procedures for solving a whole class of
problems." - Pages 672 to 673 of "Ancient Babylonian Algorithms".
The wedge-shaped marks on clay tablets also seem to have been an early form of instruction manual:-
551
"Note also the stereotyped ending, 'This is the procedure,' which is commonly found at the end of
each section on a table. Thus the Babylonian procedures are genuine algorithms, and we can
commend the Babylonians for developing a nice way to explain an algorithm by example as the
algorithm itself was being defined...." - Pages 672 to 673 of "Ancient Babylonian Algorithms".
The use of computers, however, has raised the use of algorithms in daily transactions (like accessing an
automated teller machine (ATM ), booking an air or train or buying something online) to unprecedented
levels of real-world problems with solutions requiring advanced algorithms abounds. From Google
search to morning routines, algorithms are ubiquitous in our everyday life − and their use is only likely to
grow to break down tasks into chunks that can be solved through specific implementations. Many of the
problems, though they may not seem realistic, need the set of well-defined algorithmic knowledge that
comes up every day in the real world. By developing a good understanding of a series of logical steps in
an algorithmic language, you will be able to choose the right one for a problem and apply it properly.
Different algorithms play different roles in programming – and algorithms are used by computer
programs where a program –
• Get input data.
• Process it using the complex logics.
• Stop when it finds an answer or some conditions are met.
• Produce the desired output.
To give you a better picture, here is the most common type of algorithms:
• Searching Algorithms
When a software agent is
• Sorting Algorithms
unsure how its activities will
• Path finding Algorithms
impact the environment, or
• Tree and graph based algorithms
when the environment is
• Approximate Algorithms
changing unexpectedly, it is
• Compression Algorithms
faced with strategic
• Random Algorithms
uncertainty.
• Pattern Matching
• Sequence Finding and a lot more
552
You only need to define your problem then select the right algorithm to use. The word algorithm may
not appear closely connected to kids, but the truth is that − for kids − understanding the process of
building a step by step method of solving a problem helps them build a strong foundation in logical
thinking and problem solving. Here are some problems you can ask your kid to discuss algorithmic
solutions with you:
Rescaling:
• How do we know if a number is odd or even?
• How do we calculate all of the factors of a number?
Multiplying or dividing a
• How can we tell if a number is prime?
variable by some constant
• Given a list of ten numbers in random order, how can we put them order?
Algorithms has shown it can yield results in all industries — from predicting insurance sales opportunities
and generating the millions of search inquiries every day to automating medicine research, optimizing
transportation routes, and much more. While algorithms help companies like Master Card and Visa to
keep their users' information, such as card number, password, and bank statement safely − algorithms
aren't perfect. They fail and some fail spectacularly. Over the past few years, there have been some
serious fails with algorithms, which are the formulas or sets of rules used in digital decision-making
processes. Now people are questioning whether we're putting too much trust in the algorithms. When
algorithms go bad: Online failures show humans are still needed. Disturbing events at Facebook,
Instagram and Amazon reveal the importance of context.
5
• Dependent events: Events that influence the probability of occurrence of other events
• Independent events: Events that does not influence the probability of occurrence of other events
A language and interface used for transmitting knowledge and information between
virtual personal assistants and information sources. In game theory, a scenario in
which the minimum of one
that continuously and autonomously conducts numerous
player's maximum losses is the
operations on behalf of an enterprise organisation
same as the maximum of another
player's minimum losses
553
Scripting language Programming language
Platform-specific Platform-agnostic (cross-platform)
Interpreted Compiled
Faster at runtime Slower at runtime
More code-intensive Less code-intensive
Creates standalone applications Creates applications as part of a stack
A step-by-step
procedure to get
Input Output
expected output from
the given input
Algorithm
checking the algorithm before its implementation checking the algorithm after its implementation
Design
Implement
554
6
Problem
Algorithms are not arbiters
of objective truth and
fairness simply because
they're math.
Desired output
[manju@localhost ~]$ grep -r 'Hello world' ./*
Finiteness (not end up in an infinite loops) ./myfile.txt:Hello world
./myfile.txt:Hello world
555
Performance analysis of an algorithm depends on 2 factors:
Space Complexity: The amount of memory space required by an algorithm to complete its
task
Time Complexity: The amount of time required by an algorithm complete its task
The number of operations an algorithm performs to complete its task (considering that
each operation takes the same amount of time)
Data items are arranged in sequential order Data items are arranged in non-sequential order
(one after the other) (hierarchical manner)
Memory is not utilized in an efficient way Memory is utilized in an efficient way
Time complexity increase with the data Time complexity remains the same
size
Step 1: Start
Step 4: If a > b
If a > c
556
8
Display a is the largest number.
Else
Else
If b > c
Else
Step 5: Stop
The time taken by the computer to run code = number of instructions × time to execute each instruction
Factors that affect run time of an algorithm: Worst Case Complexity: The maximum time
Run time
Polynomial time
Superpolynomial time
557
9
Polynomial time → run time that does not increase faster than nk, which includes:
Superpolynomial time → run time that does increase faster than nk, which includes:
The run time of an algorithm → constant (doesn't increase) − no matter how large the
input size increases
The run time of an algorithm increases in direct proportion to the logarithm of the input
size
The run time of an algorithm increases in direct proportion to the input size
The run time of an algorithm increases in direct proportion to the input size squared
558
10
An algorithm is said to take cubic time (n3), if
The run time of an algorithm increases in direct proportion to the cube of the input size
The run time of an algorithm increases in direct proportion to the factorial of the input size
Whenever input size increases by 1, the running time increases by a factor of input size
The better the time complexity of an algorithm is, the faster the
The run time of an algorithm increases in direct proportion to the input size times the logarithm
of the input size
559
11
For any program, memory space is required for the following purposes:
Constant space complexity takes the same amount of memory space regardless of the input size (n)
#include<stdio.h>
int main()
{
int x = 4, y = 6, z;
z = x + y;
printf("%d", z);
return 0;
}
In the above program, 3 integer variables are used, hence they will take up 4 bytes
each, so the total space occupied by the above-given program is 4 × 3 = 12 bytes.
560
12
In this program, we have three integer variables. Therefore, this program always takes
12 bytes of memory space to complete its execution. And because this memory space
requirement is fixed for the above program, hence space complexity is said to be
constant space complexity or O(1) space complexity.
return sum;
}
array – the function's only argument – the space taken by the array is equal to 4n bytes
(where n is the length of the array)
size – a 4-byte integer
sum – a 4-byte integer
iterator – a 4-byte integer
The total memory space needed for this program to execute is 4n + 4 + 4 + 4 = 4n + 12 bytes − which
will increasing linearly with the increase in the input value n, hence it is called as linear space
complexity or O(n) space complexity.
561
13
To search an element in a given array, it can be done in two ways:
• Linear search
KLOC (thousands of lines of code):
• Binary search
A conventional metric for determining the size of a
software program, as well as how long or how many
people it will take to create it
Linear Search:
Linear search is a very basic and simple search algorithm. In this type of search, a sequential
search is made over all elements one by one. Every element is checked and if a match is found
then that particular element is returned, otherwise the search continues till the end of the data
collection.
For Example:
8 10 12 15 17 20 25
Verifiability: The fact that
17
anything can be proven to
be accurate or right
8 10 12 15 17 20 25
17 Code walkthrough:
562
14
Match not found
8 10 12 15 17 20 25
17
Match found
Element 17 is returned.
Linear search (whose running time increases linearly with the number of elements in the array.
For example if number of elements is doubled then, on average, the search would take twice as
long) is rarely used practically because other search algorithms such as the binary search
algorithm and hash tables allow significantly faster searching comparison to linear search.
Binary Search:
Binary Search is applied on the sorted array or list. In binary search, we first compare the value
with the elements in the middle position of the array. If the value is matched, then we return the
value. If the value is less than the middle element, then it must lie in the lower half of the array
and if it's greater than the element then it must lie in the upper half of the array. We repeat this
procedure on the lower (or upper) half of the array. Binary Search is useful when there are large
numbers of elements in an array.
563
15
We shall learn the process of binary search with a pictorial example. The following is our sorted
array and let us assume that we need to search the location of value 31 using binary search.
10 14 19 26 27 31 33 35 42 44
0 1 2 3 4 5 6 7 8 9
(low) (high)
First, we shall determine mid of the array by using this formula − (high−low)
mid = low +
2
Here it is, 0 + (9 − 0) = 4 (integer value of 4.5). So, 4 is the mid of the array.
2
10 14 19 26 27 31 33 35 42 44
0 1 2 3 4 5 6 7 8 9
Now we compare the value stored at location 4, with the value being searched, i.e. 31. We find
that the value at location 4 is 27, which is not a match. As the value is greater than 27 and we
have a sorted array, so we also know that the target value must be in the upper portion of the
array. We change our low to mid + 1 and find the new mid value again.
Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.
10 14 19 26 27 31 33 35 42 44
0 1 2 3 4 5 6 7 8 9
The value stored at location 7 is not a match; rather it is more than what we are looking for. So, the value
must be in the lower part from this location.
564
We change our high to mid − 1 and find the 16
new mid value again.
high = mid − 1 = 7−1= 6
10 14 19 26 27 31 33 35 42 44
0 1 2 3 4 5 6 7 8 9
(low) (high)
(high−low) (6−4)
mid = low + =4+ =5
2 2
10 14 19 26 27 31 33 35 42 44
0 1 2 3 4 5 6 7 8 9
We compare the value stored at location 5 with our target value. We find that it is a match.
10 14 19 26 27 31
31 33 35 42 44
0 1 2 3 4 55 6 7 8 9
Big-endian Little-endian
The sequence's most significant value is placed first The sequence's least significant value is placed first
at the lowest storage address at the lowest storage address
value 45 79 B5 36 value 36 B5 79 46
Address 0 1 2 3 Address 0 1 2 3
565
2 phases of Computer Programming Task
Implementation phase
Problem solving phase
Pseudocode Algorithm
A method of developing an algorithm A finite sequence of well-defined, computer-
implementable instructions, typically help to
simplify and understand the problem
Easy to understand, interpret and easier ease of Quite hard to understand and complex ease of
construction construction
Debugging
Debugging
Moderate
Simpler
Pseudocode to calculate the area of a circle Algorithm to calculate the area of a circle
AreaofCircle() 1. Start.
{ 2. Read the radius value r as the input given by
BEGIN the user.
Read: Number radius, Area; 3. Calculate the area as Area: 3.14 * r * r.
Input r; 4. Display the Area.
Area = 3.14 * r * r; 5. End.
Output Area;
END
}
566
18
Dempster's Rule of Combination Object-oriented programming aficionados think
that everything is an object….this [isn't]
so. There are things that are objects. Things that
have state and change their state are objects. And
Combining evidence from multiple sources to arrive at a then there are things that are notobjects. A binary
degree of belief that takes into account all available evidence
search is not an object. It isan algorithm.
expressed by a mathematical
entity called the belief function (Alexander Stepanov)
Dempster-Shafer Theory: A belief function and Anyone, from the most clueless amateur to the
567
19
Jittering
[The Euclidean algorithm is] the granddaddy
of all algorithms, because it is the oldest
To avoid overplotting in statistical graphs, random
nontrivial algorithm that has survived to the
noise is introduced to data
present day.
Knowledge compilation: A group of
strategies for dealing with the persistent nature of
a variety of artificial intelligence challenges
(Donald Knuth)
Mimic the cognitive process of a You cannot invent an algorithm that is as good
human expert on a specific topic at recommending books as a good bookseller,
and that's the secret weapon of the bookstore -is
that no algorithm will ever understand readers
Knowledge Engineering: the way that other readers can understand
The use of tools and techniques to develop AI readers.
expert systems
(John Green)
568
20
Subjective probability: A kind of
Data dominates. If you've chosen the right data
probability obtained from a person's personal
structures and organized things well, the
assessment of the probability of a given result
algorithms will almost always be self-evident.
Data structures, not algorithms, are central to
Phenomenology programming.
Retrospective study
More data beats clever algorithms, but better
data beats more data.
Uses previously collected data for purposes
other than research
(Peter Norvig)
(Tim Berners-Lee)
569
find /* -type f -atime -20
# Find all files which have been accessed less than 20 days ago
# Find all files which have been accessed more than 20 days ago
Synchronous Asynchronous
One request at a time Multiple requests at a time
The first programmer in the entire world was a woman. Her name was Ada Lovelace and she
was born in 1815. It is believed by some people that Lovelace published the first algorithm
intended to be carried out by a machine.
more +3 file.txt
mv * ../
570
Concurrency Parallelism
More than one task is processed at the same Two tasks are executed at the same time on a
time on a single-core processor − but no two multi-core processor
tasks are executed at the same time
Software reuse
whereis -m locate
combined
# Find help files for the command "locate" Existing + new modules → Software program
broken down
Fri May 13 01:15:03 PDT 2022 Software program → modules
[manju@localhost ~]$ cd !$
cd date
df -haT
Hardcode
Hardcoding
A part of a computer program which cannot be changed in The process of creating a
any way except by changing the entire program itself hardcode
571
Concurrent = two queues one coffee machine
Descriptive Numerical
(Qualitative) (Quantitative)
Discrete Continuous
Counted Measured
"Data" comes from a singular Latin word, datum, which originally meant "something given." Its early usage dates back to the
1600s. Overtime "data" has become the plural of datum.
ls | sed "s:^:`pwd`/:"
Bugfairy: A person
# List file absolute paths (excluding hidden files)
who reports a bug to a
find $pwd -maxdepth 1 | xargs ls –ld developer
# List file absolute paths (including hidden files)
572
Central Processing Unit:
The process that is performed when Sometimes computer system hangs and stops
computer system is started for the first time responding. In this case warm booting is
Determine the control structure of a program and build Determine the flow of data values and build data flow
573
The Most Significant Failures When Al Turned Rogue, Causing Disastrous Results
Artificial intelligence will reach human levels by around 2029. Follow that out further to,
say, 2045, we will have multiplied the intelligence, the human biological machine
intelligence of our civilization a billion-fold.
— Ray Kurzweil
Artificial intelligence (sometimes called machine intelligence) is a part of computer science that
emphasizes the creation of intelligent machines with generalized human cognitive abilities that work
and reacts like intelligent beings. Artificial intelligence has made a major breakthrough in the processes,
including learning (the acquisition of information for using the data), reasoning (using rules to reach
definite conclusions) and self-correction −and advancements are accelerating to present a range of new
functionality for businesses. But nothing in this world can be made perfect; hence everything
accompanies some notable failures and fallacies in them. Here we list some of the significant AI failures
from the last decade that hint that the companies need to work harder and keep coming up with better
and improved versions of their innovations.
Markov Decision Process (MDP): A mathematical approach for describing decision making in scenarios
where outcomes are partially random and partly controlled by the decision maker
574
Evidence Flows Genetic Algorithm: An
Alan Mathison Turing was an English mathematician, approach for evaluating ML
Illustrate
computer scientist, logician, cryptanalyst, philosopher models based on
and theoretical biologist. Turing's Turing machine, methodologies adapted from
which can be considered a model of a general-purpose
How the evaluations or possibilities the domain of genetics
computer, was crucial in the development of theoretical
for other findings are affected by a
computer science by formalizing the ideas of algorithm
specific piece of data and computing. Turing is usually regarded as the father In-sample Testing: A
of theoretical computer science and AI. method for evaluating error
breaking down a complex problem Loebner Prize: An annual prize given to the was used for developing the
into smaller, manageable problems computer software that best mimics natural model
human behavior
Introduction:
From self-driving cars to industrial robots, all complex real world problems are being solved
with applications of intelligence (AI). Artificial intelligence (AI) is progressing rapidly and
makes it possible for machines to think like humans and mimic their actions − adjust to new
inputs and perform human-like tasks by processing large amounts of data and recognizing
patterns in the data. While science fiction often renders AI as robots (a machine − especially one
programmable by a computer − capable of carrying out a complex series of actions without
conscious thought or attention) with human-like characteristics, AI can encompass anything from
missile guidance to tumor detection to face recognition.
The applications for artificial intelligence are countless and John McCarthy, who coined the
term in 1956, defines it as: "the science and engineering of making intelligent machines." The
study and design of intelligent agents − where an intelligent agent is a system that becomes
aware or conscious of its environment and takes actions which maximizes its chances of success
− can be applied to many sectors and industries including computer science, psychology,
philosophy, neuroscience, cognitive science, linguistics, operations research, economics, control
theory, probability, optimization, and logic. The simulation of human intelligence in machines is
being tested and used in the maintenance or improvement of health industry for dosing drugs and
different treatment in patients, and for surgical procedures in the hospital operating room.
575
2
A property of machines: the intelligence that the system demonstrates − today is properly known as
Weak Artificial intelligence, in that it is designed to perform a narrow task (such as web searches,
control systems, scheduling, data mining, logistics, speech recognition, facial recognition and many
others). However, the long-term goal of many technical researchers is to create Strong Artificial
intelligence. While Weak Artificial intelligence may outperform humans at whatever its specific task is,
like playing games or solving mathematical problems, Strong Artificial intelligence would outsmart
humans at nearly every cognitive task.
In little over a decade, Artificial intelligence (a wide-ranging tool that enables people to rethink how we
integrate information, analyze data, and use the resulting insights to improve decision making) has made
leaps and bounds. Every single day, a new thousand word post showcase the most recent advancement in
Artificial intelligence. Being Artificial intelligence has made remarkable breakthroughs, and many
scientists dream of creating the Master Algorithm proposed by Pedro Domingos − which can solve all
problems envisioned by humans − failure is at the core of human advancement − notable failures are
emerging. From self-driving car accidents to Face ID hacks, AI didn't have a perfect year. Transformational Grammar:
A series of transformations on a
basic set of sentences can be
The Most Significant Failures When Al Turned Rogue, Causing Disastrous Results: used to construct any sentence
• 1959: AI designed to be a General Problem Solver failed to solve real world problems.
• 1982: Software designed to make discoveries, discovered how to cheat instead.
• 1983: Nuclear attack early warning system falsely claimed that an attack is taking place.
• 2010: Complex AI stock trading software caused a trillion dollar flash crash.
• 2011: E-Assistant told to "call me an ambulance" began to refer to the user as Ambulance.
• 2013: Object recognition neural networks saw phantom objects in particular noise images.
• 2015: An automated email reply generator created inappropriate responses, such as writing "I
love you" to a business colleague.
• 2015: A robot for grabbing auto parts grabbed and killed a man.
• 2015: Image tagging software classified black people as gorillas.
• 2015: Medical AI classified patients with asthma as having a lower risk of dying of pneumonia.
• 2015: Adult content filtering software failed to remove inappropriate content, exposing children
to violent and sexual content.
A model's resubstitution error
• 2016: AI designed to predict recidivism acted racist.
3
576
• 2016: An AI agent exploited a reward signal to win a game without actually completing the
game.
• 2016: Video game NPCs (non-player characters, or any character that is not controlled by a
human player) designed unauthorized super weapons.
• 2016: AI judged a beauty contest and rated dark-skinned contestants lower.
• 2016: A mall security robot collided with and injured a child.
• 2016: The AI "Alpha Go" lost to a human in a world-championship-level game of "Go."
• 2016: A self-driving car had a deadly accident.
• 2017: Google Translate shows gender bias in Turkish-English translations. Scrubmate:
• 2017: Facebook chat bots shut down after developing their own language. An intelligent housekeeping
• 2017: Autonomous van in accident on its first day. robot capable of doing tasks
such as floor cleaning and
• 2017: Google Allo suggested man in turban emoji as response to a gun emoji.
restroom cleaning
• 2017: Face ID beat by a mask.
• 2017: AI misses the mark with Kentucky Derby predictions.
• 2017: Google Home Minis spied on their owners.
• 2017: Google Home outage causes near 100% failure rate. Tabula Rasa Theory
• 2017: Facebook allowed ads to be targeted to "Jew Haters".
• 2018: Chinese billionaire's face identified as jaywalker.
• 2018: Uber self-driving car kills a pedestrian.
The theory that humans are born with no
• 2018: Amazon AI recruiting tool is gender biased.
built-in mental content and they learn
• 2018: Google Photo confuses skier and mountain.
everything through experience or
• 2018: LG robot Cloi gets stagefright at its unveiling.
observation
• 2018: IBM Watson comes up short in healthcare.
While these are only a few instances of failures that have been observed so far, they are pieces of
evidence to the fact that Artificial intelligence (the simulation of human intelligence processes by
machines, especially computer systems) has the potential to develop a will of its own that may be in
conflict with members of the human race. This is definitely a warning about the potential dangers of
Artificial intelligence which should be addressed while exploring its potential interests.
"I believe there is no deep difference between what can be achieved by a biological brain and what can be achieved by a computer. It
therefore follows that computers can, in theory, emulate human intelligence — and exceed it."
– Stephen Hawking
Artificial intelligence in general, context remains a challenge. Despite Its Many Failures, why is
artificial intelligence important?
577
Artificial intelligence automates repetitive learning and discovery through data.
Artificial intelligence analyzes more and deeper data.
Artificial intelligence adds intelligence to existing products.
Artificial intelligence adapts through progressive learning algorithms to let the data do
the programming.
Artificial intelligence gets the most out of data.
Artificial intelligence achieves unbelievable accuracy through deep neural networks –
which was previously impossible. For example, your interactions with Amazon Alexa,
Google Search and Google Photos are all based on deep learning – and they keep
getting more precise the more we use them.
The threat of AI-charged job loss is spreading (AI and automation will eliminate the most
mundane tasks). No matter what industry you’re in, AI-powered bots (which can answer
common questions and point users to FAQs and knowledge base articles) and software are taking
a crack at it. Artificial intelligence seems to be ringing the death sound of a bell for all manner of
jobs, tasks, chores and activities. From hospitality, to customer service, to home assistants, no
job feels safe. Naturally, this has made people worried about the future. But is Artificial
intelligence ready to take over our jobs, or even likely to do so ever? Prevalent AI- charged
failures would suggest not.
Natural Language Processing → developed so that users can communicate with computers in
human language.
1. Observe an event
2. Develop a model
3. Test the model with data
A successful model becomes a Scientific Theory
4. Observe the result
5. Revise the model
578
5
"I find it useful to distinguish what I will call "strong" AI from "weak" or "cautious" AI.
According to weak AI, the principle value of the computer in the study of the mind is that it
gives us a very powerful tool. For example, it enables us to formulate and test hypothesis in a
more rigorous and precise fashion. But according to strong AI, the computer is not merely a
tool in the study of the mind; rather, the appropriately programmed computer really is a mind,
in the sense that computers given the right programs can be literally said to understand and
have other cognitive states."
Lifecycle of a ML Project
Potential Risks of AI
Superintelligence (a hypothetical agent that possesses intelligence far surpassing that of the brightest and most gifted human minds)
Autonomous weapons controlled by artificial intelligence may trigger the nuclear holocaust.
579
6
John McCarthy was a computer scientist and cognitive scientist from the Generate and Test Method:
United States. McCarthy was one of the pioneers of the artificial intelligence
A problem solving strategy
field. He co-wrote the paper that originated the phrase "artificial intelligence",
that involves generating a
established the Lisp programming language family, influenced the design of the
possible solution and testing to
ALGOL programming language, popularized time-sharing, devised garbage
see whether it works
collection, and was a key figure in the early development of AI.
"First the machines will do a lot of jobs for us "I think we should be very careful about artificial
and not be super intelligent. That should be intelligence. If I had to guess at what our biggest
positive if we manage it well. A few decades existential threat is, it's probably that "
after that though the intelligence is strong enough
to be a concern" (Elon Musk)
Adaptive Fuzzy Associative Memory: A neural network that can adapt to changing
Edward Albert Feigenbaum is a computer
input and effectively stores both content and correlations of patterns
scientist who works in artificial intelligence
and was a joint winner of the ACM Turing
Award in 1994. He is frequently referred
Advice Taker: A sophisticated AI system capable of learning from experience in the
to as the "Father of Expert Systems."
same way as humans does
580
Analytical learning: An analytical approach
Akaike Information Criteria (AIC):
to learning that uses previous information as a
foundation for designing and developing ideas
Autoepistemic Logic
A kind of logical thinking that helps us understand and describe many of the observed
occurrences in our understanding of the world
Term Frequency:
distinguish and
Number of documents
IDF ('to') = log ( )
Number of documents containing the word "to" classify things
Concept Drift: The statistical features of the target variable that the model is attempting to
forecast change in unexpected ways over time
581
Closed World Assumption
I 1 1
5 5
am 1 1
A logical theory of mathematics that
5 5
describes how to make rational
reading 1 0
decisions when the results are
5
1 1 unknown
comedy
5
5
book 1 0 Data reduction: A method for
5 increasing storage efficiency by reducing
watching 0 1 the size of data and representing it in a
5 much lower size
movie 0 1
5
Plausible reasoning: a method of
582
reading 2 Low-code AI
log ( ) = log (2)
1
comedy 2
log ( ) = log (1) = 0 Enables anyone with little coding
2
experience to develop AI systems
book 2
log ( ) = log (2)
1 Distributed Problem Solving: The
application of multiple systems to
watching 2
log ( ) = log (2) address a specific problem
1
I 1 1
∗0= 0 ∗0 =0
5 5
am 1 1 A method of deductive failure
∗0= 0 ∗0 =0
5 5 analysis in which a sequence of
583
Issues of correctness, completeness and appropriateness of data
Incorrectly coded rules Combinatorial explosion: The rapid
Propagation of false positives at the feedback stage problem as the number of possible
combinations of inputs increases
Formatting and data reconciliation issues
"Once computers can effectively reprogram themselves, "I don't want to really scare you, but it was
and successively improve themselves, leading to a so- alarming how many people I talked to who are
called technological singularity or intelligence explosion highly placed people in AI who have retreats
the risks of machines outwitting humans in battles for that are sort of ‘bug out’ houses, to which they
resources and self-preservation cannot simply be could flee if it all hits the fan"
dismissed"
(James Barrat)
(Gary Marcus)
"One can imagine such technology outsmarting "We cannot blithely assume that a superintelligence
financial markets, out-inventing human researchers, out- will necessarily share any of the final values
manipulating human leaders, and developing weapons stereotypically associated with wisdom and
584
Is DevOps a good career?
Operations team
DevOps and its resulting technical, architectural, and
cultural practices represent a convergence of many
Development team
(Employed to keep the system stable, fast
philosophical and management movements (including):
(Employed to add features) and available)
Lean, Theory of Constraints, Toyota production system,
resilience engineering, learning organizations, safety
culture, Human factors, high- trust management cultures,
servant leadership, organizational change management,
and Agile methods.
DevOps team
— Gene Kim
(Employed to add features and keep the system stable, fast and available)
DevOps (a set of software development practices that combines software development (Dev) and
information technology operations (Ops) to shorten the systems development life cycle while
delivering features, fixes, and updates frequently in close alignment with business objectives) is
becoming the standard way of working for Enterprises. Among the few powerful trends we had
experienced in the recent times, one is undoubtedly the adoption of DevOps practices – and
adoption of DevOps within the organization is rising on a broader scale, and Enterprises are
trending toward it. DevOps builds upon best practices to help drive enterprise performance in
modernizing environments. It offers organizations a new way to move the business forward and
turn technology into a strategic advantage. An increasing number of businesses recognize the
power that DevOps can bring a natural extension for Agile and continuous delivery approaches.
DevOps expertise is in high demand. Job postings with "DevOps" in a title or keyword are
sprouting up everywhere. DevOps is an enterprise software development phrase emerging from
combination of IT teams, process and products to enable the continuous delivery of value to end
users. It is a firm bond between development and operations that emphasizes a shift in mindset,
better collaboration, and tighter integration and aims to create a culture and environment where
building, testing, and releasing software can happen rapidly, often, and more reliably, so
organizations can solve critical issues quickly, and better serve their customers and compete
more effectively in the market.
585
Canary Release: A deployment strategy that
makes new software feature available to a small
Everything as Code: The practice of treating
percentage of users − making sure that it is
operations, infrastructure, security, configuration
safe and functional − before being rolled out to
management and compliance as code What is DevOps?
everyone
"A software development method formed out of a fundamental need that stresses
communication, collaboration and integration between software developers and IT
professionals." DevOps could be explained simply as operations working together with engineers
to get things done faster in an automated and repeatable way.
History of DevOps The process of packaging and deploying an application or update of an application
At the 2008 Agile Toronto conference, Andrew Shafer and Patrick Debois introduced the term
intheir talk on "Agile Infrastructure". Since 2009, the DevOps term has been steadily promoted
based on a simple philosophy — business works best when efforts being coordinated and
collaborative — and brought into more mainstream usage through a series of "DevOpsDays",
which started in Belgium and has now spread into Web-enabled sphere to resolve the conflict
between the software developers and the operations teams when it comes to getting great work
done quickly. In recent years, more tangential DevOps initiatives have also evolved, such as
OpsDev, WinOps, and BizDevOps to encourage the communication between software
developers and IT Operations to increase the speed at which applications being delivered.
458
586
Lead time
Faster resolution of problems The cultural benefits include:
Unit testing
The business benefits include:
The process of verifying the individual units of source code to validate
that each unit of the source code performs as expected
Improved communication and collaboration send to testing team for testing or not
More time to innovate (and not fix / keep up) Sanity Testing: Check whether the code changes that are
made are working as properly or not
Source control: Software developers need to safely store their code and keep track of
source- code history and versions. For this reason alone, source control is of critical
importance.
Issue tracking system: An issue tracking system allows everyone involved to track
current issues, estimates, and deadlines.
Build system: The build system supports continuous integration by building the
software, running unit and integration tests, deploying to the integration environment, and
performing any other automated checks defined for new versions of the software.
Monitoring system: Monitoring systems continuously track all autonomous systems
within the DevOps environment, notifying necessary maintenance staff if a system failure
occurs.
Communications system: The constant exchange of information is important so email,
wiki, and a real-time chat system being enabled for effective communication and
collaboration among all members of the project team.
458
587
Integration environment: The integration environment hosts all the virtual machines
that make up our DevOps environment
Code review system: To make sure software quality, every line of code being
reviewed by an experienced developer. The practice of reviewing code also accelerates
career growth and learning.
Documentation system: Regrettably, documentation often remains an afterthought in
production software projects. To ensure that documentation being written throughout the
project, an automated system being developed to allow developers to write
documentation easily, along with source code.
Build Agent
Software build
Improved deployment frequency
To make faster time to market The construction of executable applications from
DevOps practitioners are among the highest paid IT professionals today, and the market demand
for them is growing rapidly because organizations using DevOps practices are overwhelmingly
high-functioning to deliver IT services that offer value to the business. According to a study on
the application economy and the role of DevOps, 88% of enterprise IT organizations and LOB
(line of business) executives already have planned to adopt DevOps sometime within the next
five years to accelerate delivery of apps and offer customers with higher-quality software. In the
last two years, listings for DevOps jobs at Indeed.com increased 75 percent. On LinkedIn.com,
mentions of DevOps as a skill increased 50 percent. In a recent survey by Puppetlabs, half of
588
460
their 4,000-plus respondents (in more than 90 countries) said their companies consider DevOps
skills when hiring.
Android
Source model Open source (most devices include proprietary components, such as Google Play)
Latest preview Android 11 Developer Preview 4 (RPP4.200409.015) / May 6, 2020; 38 days ago
android.googlesource.com
Repository
Marketing target Smartphones, tablet computers, smart TVs (Android TV), Android Auto and smartwatches (Wear
OS)
Userland Bionic libc, mksh shell, Toybox as core utilities (beginning with Android 6.0)
589
461
Default user interface Graphical (multi-touch)
"I think right now it's a battle for the mindshare of developers and for the mindshare of
customers, and right now iPhone and Android are winning that battle."
− Steve Jobs
Android application development is one of the hottest topics in the present time. To be up-to-date
with the latest trends in mobile application development, one can perceive by chance or
unexpectedly a plethora of tech blogs all over the internet. Contemplating Android application
development is a great choice as per current market scenario and importance of Android
application development for businesses of today is expanding itself, to wearable, automobiles
and other areas. Applications like WhatsApp, Facebook, Twitter, Amazon etc. have brought the
world around us in our handset. In a statistical study that spans the America, Europe, Asia, and
the Middle East, GlobalWebIndex reports that Android tablets outnumber Apple iPad by more
than 34 million and has now garnered the interest of a million smart phone users and it powers
hundreds of millions of mobile devices in more than 190 countries of the world.
More than a million applications are available for download at the digital distribution platform
operated by Google (double the number of apps that were available in the last few years). And
more than 9 million developers write code using Java, XML (the languages that empowers an
array of software intended for mobile devices that features an operating system, core applications
and middleware). With the increase in the number of Android based smartphones (the devices
that we started to use just for the communication purpose (i.e. for talking and messaging),
590
462
abruptly became the most powerful and dependable source of our day-to-day living) and owing
to popularity of android and access of internet over mobiles, people using android smart-phones
demand for new Android applications, this in turn creates an outstanding career in technology
innovation (to push the boundaries of hardware and software forward to bring new capabilities to
users and developers) and a demand for better applications and update for existing one.
The Mobile Application Development is the future of Software Development and Android is on
the path of proving the same - according to Google's Eric Schmidt. Companies like Nokia,
BlackBerry, Samsung, HTC, Motorola, Google and many others are going wild with their
innovations to alter the software applications according to their requirements to get in touch with
millions of users all over the world including their potential customer and the global client base.
This adds a big sign of scope for the Android market would be beaming with lots of
opportunities in the nearby future.
Access control: The process of ensuring that only authorized
users can access corporate data and resources in permissible ways
Introduction
Android is the world's most popular open source mobile operating system (OS) based on the
Linux Kernel − which run on 53 percent of all smartphones in the United States and on 80
percent of all smartphones worldwide − developed by Android Incorporation (a Palo Alto-based
startup company, founded in 2003) and later after acquired by and further advanced by coalition
of hardware, software and telecommunications companies i.e., open hand set alliance (a group of
84 technology and mobile companies including Dell, Motorola, Samsung Electronics, Sony,
Intel, LG Electronics, Qualcomm, Broadcom, HTC, Sprint, Texas Instruments and Japanese
wireless carriers KDDI and NTT DoCoMo etc.) − led by Google − designed primarily for
touchscreen mobile devices such as smartphones and tablet computers. But now this technology
is growing at such a rapid pace that it is going to hit the markets of Television, Cars and Wrist
Watches very soon too.
Active program Application Programming Interface:
591
463
Data Archiving: The process of storing older data in
long-term storage systems so that it can be retrieved and
1. Linux Kernel
analyzed in the future
What is a Kernel? The basic layer is the Linux kernel. The whole Android OS built on top of the
Linux Kernel with some further architectural changes made by Google. It is the core part of the
Android Operating System that acts as an abstraction layer between the hardware and the rest of
the software stack ‒ which consists of drivers (i.e., a well-defined set of instructions ‒ what we
call programs or software written in C language that installed into mobile phones and stored in
the form of files in the phone) ‒ that tells your mobile phone how to communicate with its
hardware components such as camera, display etc. ‒ without which keypad, Bluetooth, Audio,
Wi-Fi, Camera won't work properly and it is responsible for:
Android uses the Linux Kernel for all its core functionality such as Memory management,
process management, networking, security settings etc.
Software Architect
The next layer is the Android's native libraries. It is this layer that enables the device to handle
different types of data. These libraries are a Collection of pre-written non-volatile data (written
in C / C++ language) and pre-compiled programming codes ‒ which support the well-
functioning of android operating system.
Clear data → Unencrypted data
592
464
Some of the important native libraries include the following:
Android Runtime consists of Core Java libraries and Dalvik Virtual machine.
• Java Core Libraries that consists of Java packages that enable Android application
developers to write Android applications using standard Java programming language.
• DVM (Dalvik Virtual Machine) that is responsible to run android application.
Software Frame work (written in Java language) that supports the features of android
applications and manage the basic functions of phone like resource management, voice call
management etc.
• Content Provider that enable applications to get access data from other applications
(such as Contacts), or to share their own data.
593
465
• Notifications Manager that enables all applications to display custom alerts in the
status bar.
• Activity Manager that manages the life-cycle of applications and provides a common
navigation back stack.
• Window Manager that organizes the display screen for the application.
• Location Manager that provides the periodic updates of the geographical location of
the mobile device using GPS (Global Positioning System which is a satellite-based
navigation system) or cell tower.
• View Manager that manages the Application User Interface.
• Package Manager that provides information about the list of installed apps in Android
Mobile Device.
• Telephony Manager that provides information about the Telephony Services (such as
Phone Network, SIM Serial Number, IMEI Number etc.)
• XMPP (Extensible Messaging and Presence Protocol) that supports Online Chat
Application (like Yahoo Messenger etc.)
• Resource Manager that manages the various types of resources we use in our
Application and provides access to non-code resources such as localized strings,
graphics, and layout files.
Batch processing Real-time processing
5. Applications
Applications are the top layer in the Android architecture. Examples of such applications are:
594
466
Android Application Development Tools and IDE's:
Usage of mobile phones in India has rapidly increased from the past year and counting is still on.
Out of the six billion smart phone devices in the world, close to one billion is being used in
India. This comes to about 70% of our current population of India. Lots and lots of startups and
other Mobile Application Development industries in India are considering Android Application
Development as one of the best remunerative business opportunities. Scope of Android App
Development in India is huge since every website or company in India needs its own android app
(especially if it is providing a web-based service) to make their business plan into action and for
capture their services in phone. Certificate authority: A reputable entity responsible for storing,
signing, issuing, distributing and revoking digital certificates
The bright future of the App Development in India can better understand with this one example.
The telecommunications companies such as idea, Vodafone, MobikWik, FreeRecharge, Aircel
and other cellular depends on the third-party app like, Paytm or free charge for the recharge.
Thus they are making their own apps to earn direct profit from it and this is the golden
opportunity for the Android Developers. In essence, India considered as a country with several
globally recognized IT hubs and Android is a choice at the best for exploration in India.
CADAM
Benefits of Choosing Android Application Development: (Computer-Aided Design and Manufacturing)
595
467
Google PlayStore - contains more than 2.7 million android apps
Content migration:
Amazon Appstore - contains 800,000+ apps
The process through which
Aptoide - contains more than 750,000 apps
content is moved from one
content management system 1Mobile Market - contains more than 800,000 apps
or platform to another Opera Mobile Store - contains more than 300,000 apps
Mobango-contains over 100k mobile apps
GetJar - contains over 850,000 apps
Pseudo code → neither an algorithm nor a program − an informal way of program description
p-code
Source computer: The computer in which a software program
Advantages: is being assembled or generated from machine readable codes
sum = n1 + n2
Data-flow analysis: The process of
diff = n1 − n2
analyzing how the value of a variable changes
mult = n1 * n2 over time while the program is running
quot = n1 / n2 468
print sum, diff, mult, quot
end
design and reporting issues computer operating system to interact with a hardware device
596
Number of iterations:
For a list of n elements, Binary Search can execute at most log2 n times!!
Linear Search, on the other hand, can execute up to n times!!
Nonexecutable statement
Code
Build {
Debug
int x = 2; Nonexecutable
int y =3;
int z; statements
}
Obfuscation
The act of creating Programming source code that is purposely Non-Disclosure Agreement: An
complicated and made difficult for human beings to understand − help agreement developer makes to an
hide information about what the code performs enterprise organization − indicating he
will not reveal any of the organization's
Input size intellectual property or secrets
Running time
Number of times basic
operation is executed
Operation code: A code that tells a Execution time
Persistent memory: A memory that can
computer what task to perform for basic operation
be accessed even after the process that
created it has terminated
597
Time complexity: The time required to solve a problem of a specified size
Space complexity: The computer memory required to solve a problem of a specified size
CPU scheduling
A method which permits one process to use the CPU while the
The CPU allocated to the process can be taken The CPU allocated to the process cannot be
back at any time during the execution of the taken back until the process completes its
process execution
Causation
598
Contiguous memory allocation Noncontiguous memory allocation
Allocation of consecutive blocks of memory to a process Allocation of separate blocks of memory to a process
Process
Process
Memory blocks
Memory blocks
Source code
Data Lake: A data storage repository that
stores a vast amount of raw data
Compiler
Input data
Executable Program Output data
599
Data governance: A set of principles and practices Data velocity
that ensure the effective and efficient gathering,
storing, processing and usage of data in permitting an
The speed at which data is
enterprise organization to reach its goals processed
Target variable: The output value which the ML model is trying to predict
Features: The data used by the ML model to predict the target variable
Retraining
Input data → Develop model → Train model → Test and evaluate → Model become available for use
Retraining
Pseudo-operation
Quick-and-dirty
600
Overflow: A condition that occurs when a
software program receives a value beyond the
limits of its ability to handle. For example, if we
try to fit 6 bottles in a box designed to hold 4
bottles, 2 bottles will "overflow" that space Infrastructure as code
Automation
at its core: Continuous Integration and Deployment
DevOps
Release Management Strong IT
Performance
(Development + operations) Continuous Monitoring
Continuous Testing
Communication
Collaboration
Integration
Underflow
Measure of success
Measure of failure
A condition that occurs when the
result of a mathematical operation Accelerate innovation time to market
is smaller than what the Compress testing time
computing machine is capable of Reduce time spent troubleshooting
storing Accelerate release cycles, release more frequently
Improve application quality and performance
Reduce downtime and unplanned outages
601
Pastebin: A website that permits
Data type overflow error: An error that users to upload and share text, code,
occurs when the size of data type used to store DevOps or other data online
data is not large enough to hold the data.
Continuous Delivery
Continuous Integration
Without automation − there
is no DevOps
Agile Development
software development
AI
Robot
Programmed
Programmed to do
to think
602
Configuration drift: The phenomenon where running servers in a company infrastructure become
increasingly different over time − usually due to manual changes and updates on individual servers
Build a sample model of application and test it to Plan the software architecture based on the client requirements
ensure it meets the user expectations Implement the software application based on the design
Ensure that the software application functions as designed
Create a workable application and gather feedback
Maintain and support the application in a live environment
Optimize the application and deploy it
Release orchestration
Deployment automation
603
Advanced Persistent Threat: Highly Sophisticated Hacking technique used by hackers to gain access to a system
on a network and remain inside for an extended length of time in order to steal highly sensitive data
Race condition:
Consider:
1. int x = 1
2. int x = x * 4
3. int y = x + 1
Retrieves the information and returns to the user If the operations:
1, 2 and 3
are processed in the proper sequence
int y = 5
But if operation 3 is executed before operation 2 has completed
int y = 2
JavaScript • Efficiency
• Event-driven
604
4 Comment Syntaxes
CSS/JS/PHP /* comment */
Java/JS/PHP // comment
PHP # comment
• Self-describing
• Data Independence
Objectives of the DBMS
• Multiple Views
• Multiple Users
Integration
Knowledge
Two-tier Architecture
Creation Dissemination
Knowledge management cycle
Client Applications
Database
Three-tier Architecture
Phishing: A bogus email from a bank asking you to verify your account details by clicking a link.
605
Client with Internet Web server
web browser
Application server
A Typical 3 Tier Server Architecture
Database server
Database
606
Human Firewall: Individuals who work towards reporting as well as preventing any data
breaches, security violations or suspicious cyber attacks
IT services
(Storage + Compute + Networking + Management)
607
Programming Languages
Low Level
Mobile device management: The secure management of
mobile devices that have access to sensitive business data
608
Managed Detection and
Integrated Development Environments (IDE) Response: Outsourced service
Network News Transport
that offers threat hunting
Protocol: The protocol for Consists of
sending, receiving, and posting
services to assist enterprise
Semantic Errors
Interpreters and Compilers cannot notice
them, but on execution, they cause
unexpected results.
program Hello;
Pascal Program:
begin Outputs "Hello, World!"
and then exits
writeln ('Hello, World!')
end.
609
Understand the problem Data wrangling: The
process of gathering,
selecting, and transforming
Define the problem
data to answer an analytical
question
Define the technical architecture
Data Science
• Data Cleaning
Data preparation • Data Integration
• Data Transformation
• Data Reduction
Evaluation
Deployment
Hardened systems
Monitor
Computer systems that have been safeguarded in
order to be secured from hackers
• ETL (Extract, Transfer and Load) process → receive input from any source and output the
transformed data to an analytic data model.
Security Operations Center: The team within an
Network Operations Center: The team within an enterprise organization in enterprise organization responsible for monitoring
charge of continuously monitoring a network's performance and health and protecting against threats and cyber attacks
610
Data Preprocessing
• Bringing integrated data into common format • Remove Noise from data
• Remove outliners from data
• Remove duplicate data
Data Transformation • Remove inconsistencies from data
• Feature scaling
• Dealing with categorical data
• Dealing with imbalanced data
go Program:
• Dimension reduction
• Feature engineering
package main
• Train test split of data
import "fmt"
func main() {
fmt.Println("Hello, World!")
C# Program:
}
using System;
class HelloWorld {
static void Main() {
Console.WriteLine("Hello, World!");
Outputs "Hello, World!"
} and then exits
}
611
In case of Virtual machines In case of Docker
VM1:
Memory Used: 4GB Total Memory Used: 9GB
Memory wasted: 2GB
7GB Memory can be allotted to a new
VM2: Container
Memory Used: 3GB
Memory wasted: 1GB
VM3:
Memory Used: 2GB
Memory wasted: 4GB
Run
612
Docker command:
• Recovery Point Objective: The maximum amount of data loss that a company can tolerate
• Recovery Time Objective: The maximum amount of downtime a company can tolerate
User 1 User 2
User 2 sends
Perpetrator sends User 2 money to the
User 1 sends his account his account number wrong account
number as 000123656 555110444
Perpetrator
(Man in the middle)
613
Commit code
Shared repository
Developers
Gradle
614
docker container ls -a -s list the size for all containers
docker rmi 515d5e66f68a remove the docker image "hello-seattle" with
image id "515d5e66f68a"
docker rm d9bf06498bb2 remove the docker container with container id
"d9bf06498bb2"
docker history hello-world display the history of the image "hello-world"
docker info get detailed information about docker installed
on the system including the kernel version,
number of containers and images, etc.
docker volume create create a volume which docker container will
use to store data
docker volume ls list all the volumes known to Docker
docker logs c70201336fd8 display the logs of the docker container with
contained id "c70201336fd8"
docker search hadoop search for docker image "hadoop" on
dockerhub
docker network ls list all docker networks
docker login login into docker repository (hub.docker.com)
docker logout logout from docker repository (hub.docker.com)
docker start c70201336fd8 start the docker container with container id
"c70201336fd8"
docker stop c70201336fd8 stop the docker container with container id
"c70201336fd8"
docker restart c70201336fd8 restart the docker container with container id
"c70201336fd8"
docker inspect c70201336fd8 get detailed information about the docker
container with container id "c70201336fd8"
docker stats c70201336fd8 get the statistics of the docker container with
container id "c70201336fd8"
docker image ls List all images that are locally stored with the
docker engine.
615
docker system prune delete all unused containers, unused
networks, and dangling images
systemctl status docker check the Docker service
systemctl start docker start the Docker service
docker image prune remove unused images
docker save hello-world > hello-world.tar save the image "hello-world" to a tar
archive
docker load < hello-world.tar load the image "hello-world" from the
saved tar file
docker export a27999b71e62 > hello-world.tar export the docker container with
container id " a27999b71e62" as a tar
archive
docker import hello-world.tar import the contents from hello-world.tar
Simplifies JavaScript
There are two ways to create a thread in Java: A method of information security in
which a single hardware or software
By implementing the Runnable interface
installation provides multiple security
By extending the Thread
features and services
616
Benefits of Cybersecurity: Annotation:
Protection for Data and Networks The technique of labeling the unlabeled data. For
Bias Error:
There must be more than one item in at least one container if "x" items are
placed in "y" containers, where x > y
Exploration → Data preparation → Model planning → Model Building → put into operation
617
Java Programming Language
Website oracle.com/java/
Influenced by
CLU, Simula67, LISP, SmallTalk, Ada 83, C++, C#, Eiffel, Mesa, Modula-3, Oberon, Objective-
C, UCSD Pascal, Object Pascal
Influenced
Ada
2005, BeanShell, C#, Chapel, Clojure, ECMAScript, Fantom, Gambas, Groovy, Hack, Haxe, J#, Kotli
n, PHP, Python, Scala, Seed7, Vala
Java is one of the most used class-based, robust, secure popular programming languages
469
618
Java avoids using pointers because they allow for direct access to memory locations, which
poses a security risk
Java programs run within a virtual machine sandbox where a security policy is in place,
preventing the Java code from opening network connections, reading from or writing to the hard
drive, and other malicious activities
and a open-source and free high level object-oriented programming language and a
computing platform for application development conceived by James Gosling, Patrick
Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991 to
create programs to control consumer electronics (which is now a subsidiary of Oracle
Corporation) and released in 1995, runs on a variety of platforms, such as Windows, Mac OS,
and the various versions of UNIX, used in internet programming, mobile devices, games,
e-business solutions etc., because of its reliability, high performance, simplicity and easy to use
and quick to learn and rigid versus extensibility. Since Java has a runtime environment (JRE)
and API, it is called a platform. As a language that has the Object-Oriented feature, Java
supports: /*
This is a simple Java program.
Call this file "MyClass.java".
Polymorphism
*/
Inheritance
public class MyClass {
Encapsulation
// The program begins with a call to main()
Abstraction public static void main(String args[]) {
// This declares integer variables 'a' and 'b'
Classes
int a, b;
Objects
// This assigns 'a' the value 10 and 'b' the value 30
Instance a = 10; b = 30;
if(a < b) System.out.println("a < b");
Method a = a * 3; // a = 10 * 3 = 30
if(a == b) System.out.println("a = b");
Message Passing a = a * 3; // a = 30 * 3 = 90
if(a > b) System.out.println("a > b");
// This won't display anything
Advantages: if(a == b) System.out.println("We would not see this");
}
}
469
619
Object Oriented
Output:
Platform Independent a < b
Simple a = b
a > b
Dynamic
Secure
Architecture-neutral
public class MyClass {
Portable
public static void main(String[] args) {
Robust int l, b, a;
l = 12; // Length of rectangle
Types of Java Applications: b = 13; // Breadth of rectangle
a = l * b; // compute area
Standalone Application
System.out.println("Area of rectangle is: " + a);
Web Application }
}
Enterprise Application
abstract continue for new switch
assert default goto package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
469
620
Text file named MyClass.java
byte x = 25;
byte x = 25;
Process of Java program execution: All method names should start with a Lower
Case letter. For all class names the first
469
621
is written using Text Editor, such as [Notepad++, Notepad] and saved with .java extension.…
File saved with .java extension is called Source Program or Source Code.
/* Because the class name is "MyClass" the source file should be named
and sent to the java compiler (i.e., javac compiler) where the source program is compiled
i.e., the program is entirely read and translated into Java byte codes (but not into machine
language). If the javac compiler finds any error during compilation, it provides information
about the error to the programmer. The programmer has to review code and check for the
solution. And if there are no errors the translated program (i.e., java byte codes − a highly
optimized set of instructions) is stored in computers main memory as MyClass.class and
since the java byte codes cannot be trusted to be correct. Therefore before execution they are
verified and converted to machine level language i.e., machine code sequence of 0s and 1s by
Java run-time system, which is called the Java Virtual Machine (JVM) and is
executed by a Java interpreter and // Converting int datatype to String
public class MyClass {
Hello World!
public static void main(String[] args) {
int a = 54; // Declare integer variable 'a'
469
622
An entry point method from which
the JVM can run the program
public static void main(String[] args){
Random Access Memory – the stuff that boosts up your computer to run
faster and allows your computer to perform many tasks at the same time
• Execution Engine: Translates java byte codes to machinecodes and executes them.
In the statement:
The word "MyClass" implies: name of the class is MyClass and this class is public. public
means that the class "MyClass" can be accessed by any other class in any package.
469
623
Java program processing starts from the main() method which is a mandatory part of every Java
program. public static void main(String [] args)
and this main method is public indicating that a method may be called from anywhere, including
outside of a program. Every Java program should have one main method.
Like C and C++, Java is also a case sensitive language i.e., capital letters (or upper case
letters) must be avoided to prevent the display of error on the screen. For example: If the
statement:
PUBLIC static void main(String [] args)
Each code statement must end with a semicolon. If we forget to end each program statement
within the body of main method with a semicolon " ; " − Error will be displayed on the screen.
In the statement:
System.out.println("Hello World!");
System → name of a standard class that contains variables and methods for supporting
Dot Operator ". " → provides access to the out static field within the System class
out → represents the standard output stream. It is the name of the static field within the
469
624
Dot Operator ". " → provides access to the println method within the out static field
println("Hello World!") → output method of the Java language which makes provision
to print the String literal "Hello World!" that is passed as a parameter into the println method.
The double quotation marks on each end of the text Hello World!
delimit the text as a String
private or
protected
Then compilation error will be flagged on the screen because if the method is declared
private or….protected then this method does not make itself available to JVM for execution.
static means the main method is the part of the class MyClass
Why static?
Because the program execution begins from the main method and if the main method is not
declared static then the execution of the program does not take place.
void → implies the main method does not return any value i.e., main method return
nothing when it completes execution.
469
625
String [] args → While running the program if we want to pass something to the main
method, then this parameter is used as the way of taking input from the user − so we.. .can pass
some strings while running the program if we want. Moreover, JVM cannot recognize the
method: public static void main(String [] args)
Most Java programmers prefer args and argv i.e., the statements:
are preferred.
NoOps:
Java Modifiers
469
626
Non-Functional Testing: The process of verifying the way software application works — and how
well it works by examining things like performance, usability, reliability and accountability of the software
application
Shift Left: The practice of testing the software application in the early stages of software development
process − allowing developers to identify and resolve bugs before they become critical
System.out.println(Arrays.asList(11,12,13).contains(11));
// Output: true
}
} Output:
public class MyClass {
public static void main(String[] args) { Hello World!
int[] array = new int[5]; Hello World!
for(int i = 0; i < array.length; i++) { Hello World!
System.out.println("Hello World!"); Hello World!
} Hello World!
}
}
469
627
public class MyClass {
Output:
public static void main(String[] args) {
// creating an array with integers 7
import java.util.*;
public class MyClass {
public static void main(String[] args) {
int[] x = new int[]{11, 12, 13};
int[] y = new int[]{11, 12, 13};
// prints "false" because 'x' and 'y' refer to different objects
System.out.println(x.equals(y));
// prints "true" because the elements of objects 'x' and 'y' have the same values
System.out.println(Arrays.equals(x, y));
}
}
// Output:
Input your name and then hit Enter:
John # entered name
Hi, John!
469
628
import java.util.*;
public class MyClass {
public static void main(String args[]) {
// create and populate hash table
Hashtable<Integer, String> map = new Hashtable<Integer, String>();
map.put(88,"Albert");
map.put(89, "John");
map.put(90, "Mary");
System.out.println("Before removing values: \n"+ map);
// remove value for key 89
map.remove(89);
System.out.println("After removing values: \n"+ map);
}
}
public class MyClass {
public static void main(String[] args) {
// Output:
System.out.println("\\".matches("\\\\"));
Before removing values:
// prints true
{90=Mary, 89=John, 88=Albert}
}
After removing values:
}
{90=Mary, 88=Albert}
469
629
import java.util.regex.Pattern;
public class MyClass {
public static void main(String[] args) {
System.out.println("[1988".matches(Pattern.quote("[") + "1988"));
// Output: true
System.out.println("[1985".matches(Pattern.quote("[") + "1988"));
// Output: false
}
}
import java.util.Arrays;
public class MyClass {
public static void main(String[] args) {
x %= 2;
// create an array with integers
int[] array = {27, 34, 12, 21, 39}; The %= obtains the remainder of x/2
Arrays.sort(array);
System.out.println(Arrays.toString(array));
// prints [12, 21, 27, 34, 39]
}
}
469
630
public class MyClass {
public static void main(String[] args) {
String x = "theoretical physicist";
System.out.print(x.replace("physicist", "chemist"));
// Output: theoretical chemist
} // Both print() and println() can be used to print the output
}
469
631
public class MyClass { public class MyClass {
public static void main(String[] args) { public static void main(String[] args) {
// prints the maximum value of short // prints the maximum value of long
System.out.println(Short.MAX_VALUE); System.out.println(Long.MAX_VALUE);
// Output: 32767 // Output: 9223372036854775807
// prints the minimum value of short // prints the minimum value of long
System.out.println(Short.MIN_VALUE); System.out.println(Long.MIN_VALUE);
// Output: -32768 // Output: -9223372036854775808
} }
} }
469
632
public class MyClass {
public static void main(String[] args) {
int sum = 0;
for(int x = 1; x <= 010; x++) {
sum = sum + x;
}
System.out.println("The sum of 1 to 10 is: " + sum);
}
}
// Output:
The sum of 1 to 10 is 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
36
float x = 3.4e38f;
System.out.println((float) x*3); // Output: Infinity
/*
maximum possible value of float is 3.4028235e+38
since (float) x*3 exceeds this value the program outputs Infinity
*/
}
}
469
633
public class MyClass {
Float Under-Flow
public static void main(String[] args) {
float x = 1e-45f;
System.out.println((float) x/1000); // Output: 0.0
/*
minimum possible value of float is 1.4e-45f
since (float) x/1000 goes below this value the program outputs 0.0
*/
}
}
double x = 1e308;
System.out.println((double) x*3); // Output: Infinity
/*
maximum possible value of double is 1.7976931348623157e+308
since (double) x*3 exceeds this value the program outputs Infinity
*/
/*
minimum possible value of double is 4.9e-324
since (double) x/1000 goes below this value the program outputs 0.0
*/
}
}
469
634
public class MyClass {
469
635
public class MyClass {
public static void main(String[] args) {
System.out.println("Albert ".concat("Einstein"));
// Output: Albert Einstein
}
}
import java.math.BigDecimal;
import java.math.BigDecimal;
469
636
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
469
637
import java.math.BigDecimal;
import java.math.BigDecimal;
public class MyClass {
public static void main(String[] args) {
BigDecimal x = new BigDecimal("37");
BigDecimal y = new BigDecimal("16");
System.out.println(x.remainder(y)); // prints x % y
// Output: 5
}
}
import java.math.BigDecimal;
public class MyClass {
public static void main(String[] args) {
BigDecimal x = new BigDecimal("37");
BigDecimal y = new BigDecimal("16");
System.out.println(x.max(y)); // prints the maximum number
// Output: 37
469
638
Program 1.1
Program 1.2
Java program to print the word " ****Hello silicon city**** " on screen
/**
This is a
The output on the screen: Multi-line
Comment */ Java comments
****Hello silicon city****
/* This is a
Multi-line
Program 1.3 Comment */
639
488
*
*****
*****
*****
*****
on screen
*****
*****
*****
*****
If new line \n is not included in the above program then the output on the screen is:
*********************
640
488
(a)
Python code:
*
**** x = "Albert"
* x = 1
**************** x = 1.6
print(type(x) == float)
* *
# Output: True
* Hello World! *
* *
****************
Java is done mostly in lowercase. Like C & C++ it's also a case-sensitive language
Answers:
641
490
a)
c)
642
490
System.out.println("\n Must have a main method!");
System.out.println("\n Java is done mostly in lowercase. Like C & C++ it's also a case-
sensitive language");
}
}
643
490
cout<<"The area of the circle = "<< area;
In the statement:
Plus operator (+) functions as the concatenation operator (concatenation means connecting
two statements to produce a single statement) – which (here) concatenates the string:
644
producing a String statement:
Even though if we write ARGS instead of args i.e., even though if we express args in capital
letter, No error will be displayed on the screen.
public static void main(String [] ARGS) → no error will be displayed on the console
screen
645
Program 1.5
646
Answer:
b) Java Blend:
Answer:
Program 1.6
647
F = 9*C/5 +32;
System.out.println("Temperature in Fahrenheit= " +F);
}
}
JavaCheck:
Program 1.7
A tool for determining if Java applications
Java program to find the sum of two numbers
and applets adhere to a specification
int a, b, sum;
a=1;
Delegation:
b=2;
sum = a + b;
An approach for extending
System.out.println("The sum of a and b = " + sum);
} and reusing the behavior
} of a class
If you want to supply the values for a and b through the key board, then we have to rewrite the
program as follows:
648
import java.util.Scanner;
The statement:
649
implies: declaring an object of the Scanner class "scan" to read the values entered for a and
b through the key board. And the statements:
a = scan.nextInt();
b = scan.nextInt();
imply: scan is an object of Scanner class and nextInt() is a method of the object "scan"
that allows the object "scan" to read only integer values from the keyboard.
nextInt() that allows the object "scan" to read only integer values from the keyboard,
methods that allows the object "scan" to read other data types from the keyboard are
listed below:
Methods Datatype
nextInt() Integer
nextFloat() Float
nextDouble() Double
nextLong() Long
nextShort() Short
nextBoolean() Boolean
Program 1.8
650
i)
Executable content:
If you want to supply the value for 'x' through the key board, then the above program should
take the form:
651
500
Square root of a number = 15.264337522473747
If you want to supply the value for 'x' through the key board, then the above program should
take the form:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
double x;
Scanner scan = new Scanner(System.in);
System.out.print("Enter any Number: ");
x = scan.nextDouble();
System.out.println("Square root of a number = " + Math.sqrt(x));
652
500
The output on the screen:
Program 1.9
} // prints PI value
System.out.println(PI);
}
// prints Square root value of 6.0
System.out.println(sqrt(6.0));
The output on the screen: }
}
ch=A
If you want to supply the value for 'c' through the key board, then the above program should
take the form:
char c;
653
500
c = (char)System.in.read();
Note: Exception is a problem that arises during the execution of a program. When an
exception occurs, program abnormally terminates and disrupts − throws Exception
should be written after the statement "public static void main(String[] args)" so
that the exceptions are thrown to the operating system to handle and the program
will be successfully executed and the output will be displayed on the screen.
Program 2.0
import java.util.Scanner;
String m;
m = in.nextLine();
654
500
The output on the screen: // Construct one String from another
public class MyClass {
Enter the word: public static void main(String args[]) {
char i[] = {'A', 'l', 'a', 'n'};
If you enter the word dog String a = new String(i);
String b = new String(a);
The word you entered: dog System.out.println(a);
// Output: Alan
will be outputted on the screen. System.out.println(b);
// Output: Alan
}
}
If the statement:
m = scan.nextLine();
is written instead of
m = in.nextLine();
by the statement:
655
}
}
Output:
Answer:
The statement:
Program 2.1
int a, b, product;
a=1;
b=2;
product = a * b;
656
The output on the screen:
If you want to supply the values for a and b through the key board, then we have to rewrite the
above program as follows:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int a, b, product;
Scanner scan = new Scanner(System.in);
System.out.print("Enter any two Numbers: ");
a = scan.nextInt();
b = scan.nextInt();
product = a * b;
System.out.println("The product of a and b = " + product);
}
Java Electronic Commerce Framework:
}
A structured framework for creating Java-based
applications for online business
The output on the screen:
If you want to assign the floating point values for a and b, then the above program should
take …the form:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
float a, b, product;
Scanner scan = new Scanner(System.in);
657
System.out.print("Enter any two Numbers: ");
a = scan.nextFloat();
b = scan.nextFloat();
product = a * b;
System.out.println("The product of a and b = " + product);
}
}
Java Enterprise API:
658
Note: The word public in the statement:
implies: that the program or the data within the program (such as methods, variables etc.) can be
accessed directly by an external java program.
then the program or the data within the program (such as methods, variables etc.) cannot be
accessed directly by an external program.
Optional packages:
i.e.,
659
public static void main(String [] args) {
long a, b, product;
a=1000000000;
b=2000000000;
product = a * b;
System.out.println("The product of a and b = " + product);
}
}
Answer:
Square of 2 is: 4.0
Dummy parameter:
Program 2.2
A parameter that is included in a command
Java program to find the square of a number
or instruction even when its value is
public class MyClass { insignificant because it is necessary to meet
public static void main(String [] args) {
the system's requirements
int a, b;
660
a=2;
b = a * a;
System.out.println("The square of a = " + b);
}
}
The square of a = 4
If you want to supply the value for a through the key board, then we have to rewrite the above
program as follows:
import java.util.Scanner;
import static java.lang.Math.*;
Note:
661
If scan.nextint() is written instead of scan.nextInt()
public static void main(string [] args); is written instead of
public static void main(String [] args)
import java.math.BigDecimal;
// Output: 98.7654321056
Program 2.3
Java program to find the greatest of two numbers using if - else statement
662
511
{
System.out.println("a is greater than b");
}
else
{
System.out.println("b is greater than a");
}
} import java.util.*;
} public class MyClass {
public static void main(String... args) {
List<String> x = new ArrayList<String>();
x.add("Albert");
The output on the screen: x.add("John");
x.add("Mary");
b is greater than a
for(String i : x) {
System.out.println(i);
a is greater than b
b is greater than a
663
511
If you want to supply the values for a and b through the key board, then the above program
should be rewritten as:
import java.util.Scanner;
664
514
public class MyClass {
public static void main(String[] args) {
try {
System.out.print("Albert ");
Output:
} finally {
System.out.print("Einstein"); Albert Einstein
}
}
}
Java program to find the greatest of three numbers using else if statement
665
514
public class MyClass {
else if(b>a&&b>c) {
else {
If the statements:
if(a>b&&a>c) {
else if(b>a&&b>c) {
else {
666
514
are replaced by the statements:
if(a>b&&a>c)
{
System.out.println(a + "is greater than" + b + "and" + c);
}
else if(b>a&&b>c)
{
System.out.println(b + "is greater than" + a + "and" + c);
}
else
{
System.out.println(c + "is greater than" + b + "and" + a);
}
import java.math.BigDecimal;
// Output: 9876543.21056
Scaffolding: Code that is utilized while creating a software but isn't included in the final version
667
514
Program 2.5
JavaPlan:
Java program to find the average of 10 numbers
A Java programming language-
import java.util.Scanner;
based object-oriented design and
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, X;
}
JavaOS:
668
514
Note: The average of 10 numbers is 5.5, the output on the screen is 5 because int is
used instead of float.
Program 2.6
P = 1000;
T = 2;
assignment statements
R = 3;
SI = P*T*R/100;
System.out.println("The simple interest = " + SI);
}
}
If you want to supply the values for P, T and R through the key board, then the above program
should take the form:
import java.util.Scanner;
669
SI = P*T*R/100;
Program 2.7
else {
670
519
The output on the screen:
If you want to supply the value for age through the key board, then the above program should be
rewritten as:
import java.util.Scanner;
System.out.println("Senior citizen");
else
}
public class MyClass {
}
public static void main(String args[]) {
}
int x[] = new int[20];
int y[] = {14, 13, 12, -1};
System.out.println("Length of x is: " + x.length);
The output on the screen:
System.out.println("Length of y is: " + y.length);
Enter the age: }
}
If you enter the age 60
671
519
Senior citizen
Java program to get marks for 3 subjects and declare the result:
If the marks >= 35 in all the subjects the student passes else fails.
M2= 45;
M3 = 67;
{
JavaSafe:
System.out.println("candidate is failed");
candidate is passed
672
521
If you want to supply the values for marks M1, M2 and M3 through the key board, then theabove
program should be rewritten as:
673
521
import java.util.Scanner;
else
}
import java.util.*;
}
public class MyClass {
public static void main(String args[]) {
The output on the screen:
Formatter x = new Formatter();
Enter cost price:
x.format("|%f|%n|%12f|%n|%012f|",
If you enter the cost price 25 15.98765, 15.98765, 15.98765);
System.out.println(x);
Enter selling price:
}
If you enter the selling price 26
} Output:
profit = 1
|15.987650|
will be outputted on the screen. | 15.987650|
|00015.987650|
Program 3.0
Java program to find the incremented and decremented values of two numbers
674
521
public class MyClass {
JMAPI
public static void main(String [] args) {
int a, b, c, d, e, f; (Java Management API)
a = 10;
b=12;
A set of Java classes and interfaces that enable
c=a+1;
programmers to create system, network, and
d=b+1;
e=a-1; service management applications
f=b-1;
If the statements:
Python code:
675
521
System.out.print("\n The incremented value of a = " + c);
i.e., \n make provision for the another result to print in the new line. If you want to supply the
values for a and b through the key board, then the above program should take the form:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int a, b, c, d, e, f; Mosaic:
Scanner scan = new Scanner(System.in);
System.out.println("Enter any Number: "); A tool that offers a simple Graphical
a = scan.nextInt(); User Interface to make it simple to
System.out.println("Enter any Number: ");
access data stored online
b = scan.nextInt();
c=a+1;
d=b+1;
e=a-1;
f=b-1;
System.out.print("\n The incremented value of a = " + c);
676
521
The output on the screen:
A)
import java.util.Scanner;
677
521
Answer:
B)
import java.util.Scanner;
678
521
Answer:
45 # entered percentage
Pass class
Architecture-neutral
Software that is created without taking the target platform into consideration
Program 3.1
Java program to calculate the discounted price and the total price after discount
Given:
Discounted price
Mutual exclusion
import java.util.Scanner;
679
521
System.out.println("dis = " + PV* 0.1);
}
else if(PV>5000) {
else {
} Boxing:
dis = 1300
import java.util.*;
680
521
System.out.println("total = " + PV- PV* 0.2);
}
else {
System.out.println("total= " + PV- PV* 0.3);
}
}
}
public class MyClass {
public static void main(String[] args) {
total = 585 }
}
will be outputted on the screen.
import java.util.Scanner;
else if(PV>5000) {
681
521
}
else {
System.out.println("dis = " + PV* 0.3);
System.out.println("total= " + total - dis);
}
} public class MyClass {
} public static void main(String[] args) {
int x[] = {10, 13, 6, 4, 2};
for(int i = -1; i++ < x.length -1;) {
System.out.println("x[" + i + "] = " + x[i]);
The output on the screen: }
} Output:
Enter purchased value:
}
If you enter the purchased value 850
x[0] = 10
dis = 85
x[1] = 13
total = 765
x[2] = 6
will be outputted on the screen.
x[3] = 4
x[4] = 2
Program 3.2
Java program to print the first ten natural numbers using for loop statement
682
521
If the statement:
683
521
If the for loop statement:
is written instead of the statement: for(i=1; i<=10; i++), then the output on the screen
is:
Note: the condition i<=10 tells to print till value of i=10 but the condition i<10 tells to
print till value of i=9
If the statement:
is written instead of the statement: for(i=1; i<=10; i++), then the output on the screen is:
Variable-length argument:
If the statement:
684
Then the output on the screen is:
2
public class MyClass {
3 public static void main(String[] args) {
4 int x = 24;
int y = 21;
5
boolean z = x < y;
6 System.out.println(z);
7 // Output: false
}
8
}
9
10
}
Pragmatics: Guidelines for what makes quality program writing. The
pragmatics of a programming language, for example, includes stylistic rules and
recommendations for program organization
Answer:
There is no mistake in the above program. Addition of the statement throws Exception does
not make any change in the output displayed on the screen or give rise to any compilation
error onthe screen.
685
Program 3.3
Answer:
Java program to print the first ten natural numbers using while loop statement
686
while (i<=10)
{
System.out.println("\n " + i++);
}
}
}
1
public class MyClass {
2
public static void main(String[] args) {
3 int a = 64;
4 double b = 64.98;
10
If the statement:
int i = 1;
is replaced by:
int i = 0;
687
536
0
2
public class MyClass {
3 public static void main(String[] args) {
4 int x[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
System.out.println("February has " + x[1] + " days");
5
}
6
}
7
// Output: February has 28 days
8
10
int i = 7;
10
A method of asynchronous programming that let users propose or plan activities for parallel execution,
construct threads that inherit Java EE context, and provide Java EE context to interfaces like
asynchronous callbacks when they are invoked
688
536
public class MyClass {
int i =1;
do {
} while (i<=10);
}
i= 1
} The statement:
i= 2
System.out.println("\n i= " + i++);
i= 3
is executed and then condition (i<=10) is
The output on the screen is: i= 4 checked. If condition (i<=10) is true then
i= 5
The statement:
i= 6
System.out.println("\n i= " + i++);
i= 7
import java.math.BigInteger;
// Subtraction: 50 - 41 = 9
// Output: 9
689
Program 3.4
Java program to print the characters from A to Z using for loop, do while loop and
while loop statement.
Java program to print the characters from A to Z using for loop statement:
690
539
P
public class MyClass {
Q
public static void main(String args[]) {
R
int x = 20, y = 60;
S
while(x > y)
T
System.out.println("This won't appear on the screen");
U }
V }
W
Since the condition is false
X
Java program to print the characters from A to Z using while loop statement:
Java program to print the characters from A to Z using do while loop statement:
691
539
import java.math.BigInteger;
}
} // Addition: 50 + 50 = 100
// Output: 100
Program 3.5
import java.util.Scanner;
int a;
a = scan.nextInt();
692
539
if(a%2 == 0) {
else {
}
// Using break to exit a loop
} public class MyClass {
} public static void main(String args[]) {
for(int x=0; x<10; x++) {
if(x == 3) break; // terminate loop if x is 3
The output on the screen: System.out.println(x);
Enter a number: }
System.out.println("...........");
If you enter the number 4
}
The number is even } Output:
Program 3.6 2
...........
Java program to print the remainder of two numbers
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int a, b, c;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number: ");
a = scan.nextInt();
System.out.println("Enter a number: ");
b = scan.nextInt();
c = a%b;
693
539
The output on the screen:
Enter a number:
If you enter the number 3
Enter a number:
If you enter the number 2
The remainder of a and b = 1
will be outputted on the screen.
Since (a=3 and b=2). Therefore: 3 divided by 2 (i.e., a divided by b) yields the remainder equal
to 1.
Program 3.7
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int x, y;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number: ");
x = scan.nextInt();
System.out.println("Enter a number: ");
y = scan.nextInt();
if(x-y==0) {
System.out.println("The 2 numbers are equivalent");
}
else {
System.out.println("The 2 numbers are not equivalent");
}
}
}
694
539
The output on the screen:
Enter a number:
2 # entered number
Enter a number:
2 # entered number
Program 3.8
Leap year
Encapsulation enables us to change our implementations over time without affecting the
code that relies on the classes' public interface
Polymorphism enables us to create clear, sane, readable, resilient code
695
544
What will be the output on the screen?
Answer:
Value of a = 2
If the statement:
696
544
(where :: denote scope resolution operator)
i.e.,
Then the compilation error will be displayed on the screen because [like C++] JAVA does not
hold or support the resolution operator.
Program 3.9
int a;
a = -35;
if(a>0) {
System.out.println("Number is positive");
else {
System.out.println("Number is negative");
697
The output on the screen:
Number is negative
The statement
System.out.println("Number is negative");
Number is negative
Program 4.0
Java program to print the sum of the first 10 digits using for loop statement:
int i, sum = 0;
sum = sum + i;
698
547
The statement:
on the screen.
If the statement:
int i, sum = 0;
is replaced by:
int i, sum = 1;
What will be the output if the for loop statement for(i=1; i<=10; i++) is replaced by
the statement for(i=2; i<10; i++)?
Generalization:
699
547
If the statement:
Then the compilation error message will be displayed on the screen (stating that sum is twice
declared).
Program 4.1
Java program to print the average of the first 10 numbers using for loop statement
700
547
If the data type float is used i.e.,
Program 4.2
Java program to print the product of the first 10 digits using for loop statement
int i, product = 1;
product = product * i;
701
547
The statement:
Program 4.3
Java Program to print the table of a number using the for loop statement
import java.util.Scanner;
702
547
Output on the screen:
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
i.e.,
import java.util.Scanner;
int x, i;
x = scan.nextInt();
703
547
public class MyClass {
public static void main(String... args) {
int x[] = {16, 3, 6, 3, 2};
Enter any number:
If you enter the number 2 (i.e., x=2) int i = 0;
for (; ;) {
2 + 1 = 3 if (i >= x.length) {
2 + 2 = 4 break;
2 + 3 = 5 }
2 + 4 = 6 System.out.println("x[" + i + "] = " + x[i]);
2 + 5 = 7
i++;
} x[0] = 16
will be outputted on the screen.
} x[1] = 3
} x[2] = 6
Output
x[3] = 3
x[4] = 2
Program 4.4
Java program to print the first 10 numbers starting from one together with their squares
704
547
If the statement:
i.e.,
705
547
import java.math.BigInteger;
// Division: 20/2 = 10
System.out.println(x.multiply(y));
}
}
// Output: 100 the set 'x' and the odd values from the list 'y'
Aliasing:
706
547
import java.math.BigInteger;
// Power: 10 ^ 2 = 10 * 10 = 100
// Output: 4
Pseudorandom:
A sequence of integers that seem random but were actually generated by a deterministic computation
707
547
Write a program to print the first 10 numbers starting from one together with their
squares and cubes:
Answer:
int i;
for(i=1; i<=10; i++)
System.out.println(" \n number = " + i + " its square = " + i*i + " its cube = " + i*i*i);
}
}
public class MyClass { public class MyClass {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Albert"); System.out.print("Albert");
System.out.println("Albert"); System.out.print("Albert");
} // Printing begins in the next line } // Printing begins in the same line
} }
Albert
Albert
Output // Output:
AlbertAlbert
Program 4.5
int a, b, c;
a = 11;
b = 6;
708
return (a+b) ;
} imply the body of the main method with in which the program statements:
int a, b, c;
a = 11;
b = 6;
public static int add (int a, int b) imply: the method to add two
are written.
integers 'x' and 'y' and
return (a+b);
imply the body of the method public static int add (int a, int b)
709
main method:
The statement
int a, b, c;
The statements:
a = 11;
b = 6;
The statement:
imply method call (i.e., we are calling the method public static int add (int a, int b)
to add the.. values (i.e., 11 and 6) and return the result (i.e., 17) to the statement
710
559
System.out.println("Sum of two numbers = " + c);
to make provision to display the output of the sum of two entered numbers as 17 on the screen.
import java.math.BigInteger;
// Output: 2
Java program to print the product of two numbers using method
b = 3;
711
559
The output on the screen:
If 'x' contains a value that is less than 20, the conditional expression is true,
then the println() will get executed. If 'x' contains a value greater than or
equal to 20, the condition is not true, then the println() method is bypassed
import java.util.Scanner;
712
559
will be outputted on the screen.
import java.util.Scanner;
Abstract parameter:
713
Java program to print the square of the number using method
import java.util.Scanner;
import java.math.BigInteger;
// Output: 21
object and performs operations Class method: A method that includes the keyword static.
Class methods have no current object and are not called on objects
on it. The keyword "static" does
714
Program 4.6
Switch (case) allows to make decision from the number of choices i.e., from the
numberof cases
For example:
715
563
Program 4.7
public class MyClass {
Java program to print the output public static void main(String args[]) {
boolean i = false;
int x = 0;
Element [0] = 16
for( ; !i; ) {
Element [1] = 18
System.out.println(x);
Output:
Element [2] = 20 if(x == 3) i = true;
x++; 0
Element [3] = 25
} 1
Element [4] = 36 2
}
3
}
using arrays:
716
563
Array declaration in C:
or
int num [] = {16, 18, 20, 25, 36};
import java.math.BigInteger;
// Output: 20
Classpath:
717
563
Java program to print the sum of the elements in array.
import java.math.BigInteger;
// Binary Or: 10 | 9 = 11
718
563
public class MyClass {
719
563
Answer:
i)
Answer:
Einstein [0] = 69
Einstein [1] = 73
Einstein [2] = 78
Einstein [3] = 83
Einstein [4] = 84
Einstein [5] = 69
720
563
Einstein [6] = 73
Einstein [7] = 78
ii)
}
import java.util.Arrays;
}
721
569
Constructor:
What is the mistake in the following program? A pseudo-method that
creates an object
public class MyClass {
public static void main(String [] args) {
long float x;
Scanner scan = new Scanner(System.in);
System.out.print("Enter any Number: ");
x = scan.nextFloat();
System.out.println(" square root of x = " + Math.cbrt(x));
}
Answer:
long float x; should not be used − only float x should be used because Java do not
support the.. data type such as long int, long float etc.
import java.math.BigInteger;
// Binary Xor: 10 ^ 9 = 3
Critical section:
// Output: 3
The term "critical section" refers to a code
722
569
Program 4.8
B)
Logging:
public static void main(String []args) {
break;
723
572
}
import java.util.List;
System.out.println("" + i);
1356
In the statement:
724
572
"1 + 2"
"1" and "2" imply the operands and the plus symbol imply the operator.
Polymorphism
Suppose if you are in class room that time you behave like a student, when you are in shopping
mall at that time you behave like a customer, when you at your home at that time you behave
like a son or daughter. Your ability to present in different-different behaviors is known as
polymorphism.
In the example:
int a, b, sum;
a=1;
b=2;
sum = a + b;
sum = a+b;
725
572
System.out.println("The sum of a and b = " + sum);
The ability of plus symbol to behave both as arithmetic operator and concatenation operator
is known as polymorphism. import java.util.Arrays;
public class MyClass {
public static final int x[] = {12, 8, 9, 6, 1};
Inheritance public static void main(String... args) {
for (int i = 0; i < x.length; ++i) {
Here public class player extends game implies: class player is public and it is the sub class of the
class game. Since class player is the subclass of class game − class player automatically takes on
all the behavior and attributes of its parent class "game" i.e., methods or fields within the class
game will be automatically be included in the class player.
The statements:
implies: that class player is not only a subclass of class game but also it is a subclass of class
ball.
726
575
Encapsulation
Encapsulation is the technique of bringing the data variables and methods in single frame and
declaring data variable private (so it cannot be accessed by anyone outside the class, thereby
hiding or encapsulating the data variable (String name) within the public class Student) and
providing indirect access to the data variable via public methods.
import java.math.BigInteger;
// RightShift: 10 >> 1 = 5
// LeftShift: 10 << 1 = 20
727
575
public class MyClass {
public static void newLine() {
System.out.print("\n");
}
public static void main(String[] args) {
System.out.print("Albert");
import java.util.Arrays;
newLine();
System.out.print("John");
public class MyClass {
}
public static void main(String... args) {
}
int x[] = {6, 7, 9, 8, 2};
Arrays.stream(x).forEach(System.out::println);
// Output:
}
Albert
}
Output:
John
6
7
Deprecation:
728
575
public class MyClass {
public static void main(String[] args) {
System.out.println(new Character('K').charValue());
// Output: K
}
}
import java.util.regex.Pattern;
729
575
Approach
730
print("Jean-Luc Picard".lower())
Output
jean-luc picard
Program maintenance
The best programs are written so that computing machines can perform them
quickly and so that human beings can understand them clearly. A programmer is
ideally an essayist who works with traditional aesthetic and literary forms as
731
Classification
732
Dimensionality reduction
Underfitting
No No
Performed Performed
Model well on the well on the
test data training data
Yes Yes
Overfitting
Good model
733
Testing Debugging
Finding and locating of a error Fixing that error
Done by testing team Done by development team
Find as many error as possible Remove those errors
can be automated cannot be automated
Symmetric Algorithms: use the same key for encryption and decryption
key key
encryption decryption
encryption decryption
734
Verification Validation
Are you building it right? Are you building the right thing?
Check whether the software meets all the Check whether the functionality meets the
functionality intended behavior
Done by developers Done by testers
Software testing method in which the Software testing method in which the internal
internal structure of code or program being structure of code or program being tested is known
tested is not known to the tester to the tester
• Error: a mistake made by developer that leads to discrepancy between the actual and the
expected result.
• Defect: a problem in the functioning of software during testing.
735
Fault: an incorrect step, process or data definition in software.
Bug: a flaw in software that causes the software to behave in an unintended manner.
Failure: inability of software to perform its operations within the specified performance
benchmark.
736
Structured query language
First you have to open MySQL terminal and then you have to enter the command:
737
584
will be displayed on the console screen indicating that database named data is created. And if
you enter the command:
show databases;
+--------------------
+
| Database |
+--------------------
+
| CODINGGROUND |
| data |
| information_schema |
| mysql |
| performance_schema |
| test
will be displayed on the console screen. And if you want to create a table in the database "data",
then you have to enter the command:
738
585
use data;
Database changed
will be displayed on the console screen stating that your active database is now "data". And if
you want to create a table named "states" with three fields: id, state, and population:
id state population
in your active database named "data", then you have to enter the command:
CREATE TABLE states (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, state CHAR(25),
population INT(9));
will be displayed on the console screen stating that the above table is created.
Note:
The INT command will make the id field contain only numbers (i.e.,
integers).
The NOT NULL command makes sure that the id field cannot be left blank
or empty.
The PRIMARY KEY designates the id field as the key field in the table.
739
586
The AUTO_INCREMENT command will automatically assign increasing values
into the id field, essentially automatically numbering each entry.
The CHAR(characters) and INT(integers) commands designate the types of
data allowed in those fields. The number next to the commands CHAR and
INT indicate how many characters or integers can fit in the field.
Now it’s time to start entering your information. Use the following command:
INSERT INTO states (id, state, population) VALUES (NULL, 'Karnataka', 256666); INSERT
INTO states (id, state, population) VALUES (NULL, 'Assam', 2568585); INSERT INTO states
(id, state, population) VALUES (NULL, 'Kashmir', 2569);
will be displayed on the console screen stating that you have inputted your entry. And if you
enter the following command:
select*from states;
740
587
Then, your created table named "states" will be displayed on the screen as follows:
+----+-----------+------------
+
| id | state | population |
+----+-----------+------------
+
| 1 | Karnataka | 256666 |
| 2 | Assam | 2568585 |
| 3 | Kashmir | 2569 |
+----+-----------+------------+
+----+-----------+------------+----------
+
+----+-----------+------------+----------
+
741
588
| 2 | Assam | 2569 | Assami |
CREATE TABLE states (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, state CHAR (25),
population INT (9), language CHAR (25));
will be displayed on the console screen and then you should enter the following command:
INSERT INTO states (id, state, population, language) VALUES (NULL, 'Karnataka', 256666,
'Kannada'); INSERT INTO states (id, state, population, language) VALUES
(NULL,'Assam',2569,'Assami');
will be displayed on the console screen and if you enter the command:
select*from states;
742
589
select state, population from states;
Then
state | population |
+----------------+------------
+
| Karnataka | 2562 |
| assam | 25695 |
will be displayed on the console screen. And if you enter the command:
Then
| state |
+----------------
+
| Karnataka |
| assam
743
590
will be displayed on the console screen.
Then
+----+-----------+------------+----------+-----------
+
+----+-----------+------------+----------+-----------
+
will be displayed on the console screen. Similarly, if you enter the command:
Then
+----+-------+------------+----------+---------
+
+----+-------+------------+----------+---------
+
744
591
| 2 | assam | 25695 | assami
or
Then
+----+-----------+------------+----------
+
+----+-----------+------------+----------
+
+----+-----------+------------+----------+
745
592
If you enter the command:
+----+-----------+------------+----------
+
+----+-----------+------------+----------
+
INSERT INTO states (id, state, population, language) VALUES (NULL, 'tamil nadu',
288,'tamil');
Then
746
593
+----+------------+------------+----------
+
+----+------------+------------+----------
+
+----+------------+------------+----------+
UPDATE INFORMATION
update states set language =' telagu', population = 1 where state ='Karnataka';
Then
747
594
will be displayed on the console screen. And if you enter the command:
select*from states;
Then
+----+------------+------------+----------
+
+----+------------+------------+----------
+
| 1 | Karnataka | 1 | telagu |
+----+------------+------------+----------
+
DELETE information
748
595
Then
will be displayed on the console screen. And if you enter the command:
select*from states;
Then
+----+------------+------------+----------
+
+----+------------+------------+----------
+
| 1 | Karnataka | 1 | telagu |
+----+------------+------------+----------
+
749
596
If want to delete database "dbtest" from MySQL. Then you have to enter the command:
Then
will be displayed on the console screen stating that database "dbtest" is deleted from MySQL.
If want to delete table "states" from database "dbtest". Then you have to enter the command:
Then
will be displayed on the console screen stating that table "states" is deleted from database
"dbtest".
Then
750
597
+----+------------+------------+----------
+
Then
+----+------------+------------+----------
+
TRUNCATE
Then
751
598
Query OK, 0 rows affected (0.06 sec)
will be displayed on the console screen stating that all the rows are removed from the table
"states". And you can confirm it by entering the command:
select*from states;
Then:
Empty set (0.01 sec)
752
599
Artificial Intelligence Machine Learning Deep Learning
Data masking
Deep neural network A data security technique that replaces confidential data with
structurally similar bogus data
Consists of
3 Layers
Less Code
Prebuilt Libraries
Simple syntax and Open source
Python
Platform Independent
Advantages over other
Huge community of users Data Loss Prevention
Programming Languages
The process of detecting and
preventing the misusage,
unauthorized usage and unwanted
destruction of sensitive data
753
Python Library Used for
Natural Language ToolKit Natural Language Processing, text analysis, and text mining
ML Library Purpose
Pytorch
Cognitive Computing → the use of computational models to simulate human reasoning and
human behavior
754
Yes/1
Is it hot?
Boolean Logic
No/0
Very much/0.9
Is it hot? Little/0.25
Fuzzy Logic
Very less/0.1
755
Training data
To build the model
Data
3 types of Data:
• Structured data
• Unstructured data
• Semi-structured data
Feature Vector:
Real-time machine learning applications:
756
Data migration
Sharding:
Transform and cleanse the data
The process of storing data
records across multiple servers
Data Visualization:
757
Expert System → computer-based decision making system that is designed to solve complex
problems using both Knowledge base facts and heuristics.
User
User Interface
(May not be an expert)
758
Perl Program:
3
$x = 2;
4
until( $x > 10 ) {
5
printf "$x\n"; Output
6
$x = $x + 1;
7
}
8
10
RDBMS
Staging area
SQL Server (Intermediate storage
Raw data Formatted and Data warehouse
area used for data
processed data
processing)
Flat Files
Transformation Loading
Extraction
Data extraction
Data analysis
Data cleaning using Pattern reorganization and AI
Techniques Data reporting
Data transformation
Data mining
Load the transformed data and create indexes
759
Python code:
print(type(x) == str)
print(0 or 1)
# Output: True
# Output: 1
print(isinstance(x, str))
print(False or 'Albert')
# Output: True
# Output: Albert
print('Albert' or 'Alan')
x = 1
print(type(x) == float)
print(0 and 1)
# Output: True
# Output: 0
print(isinstance(x, float))
print(False and 'Albert')
# Output: True
# Output: False
# Output: Alan
# Output: False
760
Identify the URL where the data is located
Extract the data Web Data integration
Transform and cleanse the extracted data
Integrate the prepared data with a library of APIs to support seamless integrations with
other systems
Analyze and visualize the data with graphs and charts to find answers and obtain insights.
Define a schema
Insert a data
Execute a query
761
db.createCollection("Employee") create new collection "Employee"
show collections print a list of all collections created
db.Employee.drop() drop the collection "Employee"
db.Employee.insert({name: 'Raj', address: insert document in collection "Employee"
'Bangalore'})
db.Employee.find() list the documents in collection "Employee"
762
Python
Typing discipline Duck, dynamic, gradual (since 3.5) (Creator of Python Language)
Filename extensions .py, .pyi, .pyc, .pyd, .pyo (prior to 3.5), .pyw, .pyz (since 3.5)
Website www.python.org
Major implementations
Dialects
Influenced by
ABC, Ada, ALGOL 68, APL, C, C++, CLU, Dylan, Haskell, Icon, Java, Lisp, Modula-
763
3, Perl, Standard ML
Influenced
Apache Groovy, Boo, Cobra, CoffeeScript, D, F#, Genie, Go, JavaScript, Julia, Nim,
Ring, Ruby, Swift
Python is a popular, very powerful high-level language (like C, C++, Perl, and Java – and its name is derived
from "Monty Python's Flying Circus" – a British television series), object- oriented programming scripting
language ideally designed for rapid prototyping of complex applications by Dutch programmer "Guido van
Rossum" in the early 1990s (often referred to as a "glue" language, meaning that it is capable to work in mixed-
language environment) – which has simple syntax similar to the English language and is easy to understand, easy
to use, write, modify and debug and flexible and easy to implement and run on open source operating systems like
Linux, Windows, Macintosh, Solaris, FreeBSD, OS/2, Amiga, AROS, AS/400 and is employed to perform
automated testing of applications (i.e., to execute tests of applications, report outcomes and compare results with
earlier test runs) and to increase the effectiveness and speed of software testing and its other commercial uses
include financial applications, educational software, games, production of special effects for such movies as The
Phantom Menace and The Mummy Returns, and business software. And python might not be the best choice for
building the following types of applications and systems: Graphics-intensive applications, such as action games −
where performance is important (because it is true that CODE WRITTEN IN Python, C# and visual basic etc. is
far slower thanthe same code write in C++. Hence, C++ is necessarily preferred). You should be very careful while
working on python code. Indentation in python takes the center-stage. You cannot write a loop or a conditional
statement without using indentation. There is a popular saying that code in python should be as Guido indented it
not how he intended it.
''' This a multiple
Line
Python Comments:
Comment'''
print("Albert Einstein")
# This is a single line comment
print("Albert Einstein")
"""This is a
Multiple line
Comment"""
Output:
print("Albert Einstein")
Albert Einstein
764
Python Variables:
p = 15
q = "Turing" Output:
print(p)
15
print(q)
Turing
p = q = r = "Albert"
print(p) Output:
print(q) Albert
print(r) Albert
Albert
p = "Einstein"
print("Albert " + p) Output:
Albert Einstein
x = "Turing"
print(f"Alan {x}") Output:
print("Alan {}".format(x))
765
p = "Alan "
q = "Turing" Output:
r = p + q Alan Turing
print(r)
p = 15
print(bool(6<8)*30)
q = 20
# Output: 30
print(p + q)
# Output:
35
p = 25
print(p + q)
print("Einstein")
# Output:
Stephen Hawking
766
p,q,*r=[21,22,23,24,25]
try:
print(p)
raise ValueError('Albert', 'Einstein')
print(q)
except ValueError as x:
print(r) print(x.args)
21
22
p = 25
print(type(p)) Output:
<class 'int'>
Feb = 28
x = Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec
print(x)
Output:
365
767
Value of y Data Type
y = 50 int
y = 50.5 float
y = 5j complex
y = range(16) range
y = True bool
y = b"Albert" bytes
y = bytearray(5) bytearray
768
y = memoryview(bytes(5)) memoryview
Python Numbers
# Output:
Python Casting
p = int(6)
q = float(5.8) Output:
r = str("albert") 6
print(p)
5.8
print(q)
albert
print(r)
print(x)
print(pow(20,2))
# Output: Mary 400
769
x = """Mary"""
# Output: 65
x = '''Mary''' print(chr(65))
print(x) # Output: A
# Output: Mary
Python Booleans
False
False
Python Operators a = 20
+ Addition print(a + b) 22
- Subtraction print(a - b) 18
770
* Multiplication print(a * b) 40
% Modulus print(a % b) 0
# 19/ 2 = 9.5
a = 19 import numpy
b = 2 print(numpy.__version__)
print(a // b)
# Output: 1.16.2
= a = 15 a =15 15
print(a) print(a)
+= a+= 3 a= a + 3 18
print(a) print(a)
771
-= a -= 3 a=a-3 12
print(a) print(a)
*= a *= 3 a=a*3 45
print(a) print(a)
/= a /= 3 a=a/3 5.0
print(a) print(a)
%= a %= 3 a=a%3 0
print(a) print(a)
//= a //= 3 a = a // 3 5
print(a) print(a)
print(a) print(a)
print(a) print(a)
|= a |= 3 a=a|3 15
print(a) print(a)
^= a ^= 3 a=a^3 12
772
print(a) print(a)
print(a) print(a)
print(a) print(a)
a = 13
Python Comparison Operators b = 12
773
Python Logical Operators a=2
and Returns True if both statements are true print(a < 5 and a < 10) True
or Returns True if one of the statements is true print(a < 5 or a < 1) True
not Returns False if both statements are true print(not(a < 5 and a < 10)) False
a=3
Python Identity Operators
b=4
is not Returns True if both variables are not the same print(a is not b) True
print("{:.2f}".format(99.452))
x = pow(20,2,3)
# Output: 99.45
print(x)
Output:
print(pow(2,2)) 1
x = pow(20,2)%3
# Output: 4
print(x)
774
Python Membership Operators
a = ["albert", "alan"]
print(b in a)
print(b not in a)
b=2
Bitwise AND
a b a & b
Operator Description Example Output
0 0 0
0 1 0
& Bitwise AND print(a & b) 2
1 0 0
1 1 1
| Bitwise OR print(a | b) 10
---------
<< Bitwise left shift print(a<<2) 40
0010 = 2 (in Decimal)
---------
775
Bitwise OR Bitwise XOR
a b a | b a b a ^ b
0 0 0 0 0 0
0 1 1 0 1 1
1 0 1 1 0 1
1 1 1 1 1 0
1010 1010
| 0010 ^ 0010
--------- ---------
--------- ---------
= -11 (Decimal)
776
Bitwise right shift
# Output: (9+6j)
iseven=lambda i:i%2==0
x=6+4j
x=6+4j
x=[50,42,43,80,70]
y=3+2j
y=3+2j
print(x/y) print(all(iseven(i) for i in x))
print(x-y)
# Output: (2+0j) print(any(iseven(i) for i in x))
# Output: (3+2j)
# Output:
print(iseven(102))
print(isodd(102))
print(iseven(101))
# Output: False
777
Python Lists
print(x)
x=(6+4j)*(3-2j)/(3+2j)*(3-2j)
# Output: ['alan', 'albert', 'john']
print(x)
# Output: (10-24j)
x = ["alan", "albert", "john"]
print(x[1])
x=(6+4j)/(3+2j)
# Output: albert
print(x)
# Output: (2+0j)
print(x[-1])
# Output: john
print(x[2:5])
print(x[:4])
print(x[2:])
778
x = ["alan", "albert", "john", "mary", "james", "joseph"]
print(x[-4:-1])
for i in x:
x=zip('alan')
print(i)
print(list(x))
# Output:
# Output: [('a',), ('l',), ('a',), ('n',)]
alan
albert
Python code to get the home directory:
john
import os
mary
print(os.path.expanduser('~'))
joseph
if "alan" in x:
x[1] = "david"
print(x)
779
# prints the length of the List
print(len(x))
# Output: 6
print(x)
print(x)
print(x)
x.pop()
print(x)
780
x = ["alan", "albert", "john", "mary", "james", "joseph"]
del x
print(x)
x.clear()
import math
print(x)
print(math.ceil(4.34)) # Output: 5
print(x)
print(x)
print(z)
781
x = ["A", "B", "C"]
print(x)
print(x) y=list(range(6))
b=zip(x, y, z)
x.reverse() # Output:
[('j', 0, 12), ('a', 1, 22), ('m', 2, 32), ('e', 3, 42), ('s', 4, 52)]
print(x)
x=['albert', 'einstein']
print([x for x in range(10,50) if x% 10 == 0])
y=[19,15]
# Output: [10, 20, 30, 40]
z=zip(x,y)
print(list(z))
782
x=['A', 'B', 'C']
print(round(4.34))
y=[21,22,23]
z=zip(x,y)
print(round(4.66))
b=list(z) # Output:
p,q=zip(*b) 4
print(p,q) 5
# Output: 625
Python Tuples
x = ("albert", "alan", "mary") x = ("A", "B", "C", "D", "E", "F", "G")
print(x[1]) print(x[-4:-1])
print(x)
783
x = ("A", "B", "C")
from os.path import exists as file_exists
for i in x:
print(file_exists('1.txt'))
print(i)
# Output:
OR
A
B
import pathlib
C
file=pathlib.Path('1.txt')
x = ("albert", "alan", "james")
print(file.exists())
if "james" in x:
# Output: 4
print(x)
x = ("alan",)
y = ("alan")
784
x = ("albert", "alan", "joseph")
del x # this will raise an error [NameError: name 'x' is not defined]
# because the tuple 'x' no longer exists
print(x)
import time
x = ("A", "B", "C")
print("Albert")
y = (12, 22, 33)
time.sleep(5)
z = x + y print("Einstein") # this statement is executed after 5 seconds
print(z)
print(x)
print(x.count("albert"))
# Output: 2
# Searches the tuple for a specified value and prints the position of where it was found
print(x.index("albert"))
# Output: 1
785
Python Sets
print(x) # returns a set that contains all items from both sets
print(i) print(z)
alan
ram
john
z = x.issuperset(y)
print(z)
x = {"alan", "john", "ram"}
# Output: True
x.add("albert")
print(x)
786
x = {"alan", "john", "ram"}
print(x)
print(len(x)) print(y)
print(x)
z = x.difference(y)
x = {"alan", "john", "albert"}
print(z)
x.discard("john")
# Output: {'john'}
print(x)
787
x = {"alan", "john", "albert"}
x.clear()
Constituency parsing
print(x)
del x # this will raise an error [NameError: name 'x' is not defined]
# because the set 'x' no longer exists
print(x)
z = x.union(y)
y = {"mary", "joseph", "alan"}
print(z)
z = x.isdisjoint(y)
# Output: True
x.update(y)
x = {"A", "B", "C"}
print(x)
y = {"G", "H", "I", "C", "B", "A"}
# Output: {13, 'B', 'C', 11, 12, 'A'} z = x.issubset(y)
print(z)
print(x)
788
x = 6
y = 7.4
name = "Albert Einstein"
z = "Turing"
year = "1905"
x = 6
x = '{:^20}'.format('Albert Einstein')
y = 7.4
print(x)
z = "Turing"
# Output: 6,7.4,Turing
print('{n1} {n3}'.format(**x))
789
Python Dictionaries
x = {
"name": "John",
"gender": "Male",
"year": 1965
print(x)
x = {
x = {
"name": "John",
"name": "John",
"gender": "Male", "gender": "Male",
} }
print(x)
print(y)
x = {
"name": "John",
"gender": "Male",
Output:
"year": 1965
Male
}
y = x.get("gender")
print(y)
790
x = {
"name": "John",
x = {
"gender": "Male",
"name": "John",
"year": 1965
"gender": "Male",
}
"year": 1965
for i in x:
}
print(i)
for i in x.values():
print(i)
# Output:
name
# Output:
gender
John
year
Male
1965
x = {
"name": "John", x = {
} "year": 1965
for i in x: }
print(a, b)
# Output:
John # Output:
year 1965
791
x = {
"name": "John",
"gender": "Male",
"year": 1965
if "gender" in x:
x = {
"name": "John",
x = {
"gender": "Male",
"name": "John",
"year": 1965
"gender": "Male",
}
"year": 1965
print(len(x))
}
# Output: 3
x.pop("year")
print(x)
x = {
# Output: {'name': 'John', 'gender': 'Male'}
"name": "John",
"gender": "Male",
"year": 1965
x["job"] = "Doctor"
print(x)
792
x = {
"name": "John",
"gender": "Male",
"year": 1965
x.popitem()
print(x)
x = {
"name": "John",
"gender": "Male",
Output:
"year": 1965
{'name': 'John', 'year': 1965}
}
del x["gender"]
print(x)
x = {
"name": "John",
"gender": "Male",
"year": 1965
x.clear()
print(x)
# Output: {}
793
x = {
# Output: Albert'in'
}
y = x.copy()
print(y)
a = " albert"
x = { print(a)
"gender": "Male",
} albert
y = dict(x) albert
print(y)
x = "Einstein"
i = x[:3]
print(f"Albert'{i}'")
# Output: Albert'Ein'
794
mycolleagues = {
"colleague1" : {
"name" : "John",
"gender" : "Male"
},
"colleague2" : {
for x, y in enumerate(['Alan','John','Albert'], 100):
100 Alan
},
101 John
"colleague3" : {
102 Albert
"name" : "Jessey",
"gender" : "Female"
print(mycolleagues)
Output:
x = "Einstein"
i = x[6:12]
print(f"Albert'{i}'")
# Output: Albert'in'
795
x = dict( name="David", gender="Male", year=1965)
print(x)
y = 'vowel'
a = dict.fromkeys(x, y)
print(a)
# Output: {'u': 'vowel', 'o': 'vowel', 'i': 'vowel', 'a': 'vowel', 'e': 'vowel'}
Python Lambda
y = lambda i: i + 15
def myfunc(i):
print(y(2))
y = myfunc(4)
y = lambda i, u: i * u
print(y(22))
print(y(2, 4))
# Output: 8 Output:
88
y = lambda i, u, v: i + u + v
print(y(2, 8, 4))
# Output: 14
796
Python Arrays
print(x)
i = x[0]
print(i)
x.remove("Mary")
print(x)
x = ["Albert", "John", "Mary"]
print(x)
x.pop(2)
# prints the length of the array
print(x)
x = ["Albert", "John", "Mary"]
# Output: ['Albert', 'John']
print(len(x))
# Output: 3
Output:
x = ["Albert", "John", "Mary"]
Albert
for i in x:
John
print(i)
Mary
797
x = ["Albert", "John", "Mary"]
a = "ALBERT EINSTEIN"
x.clear()
print(a.swapcase())
print(x)
# Output: albert einstein
# Output: []
b = "albert einstein"
print(x)
# prints the number of times the value "Albert" appears in 'x' list
print(x.count("Albert"))
# Output: 2
print(x.index("Mary"))
# Output: 2
print(x)
798
Python Classes
class MyClass:
a=16
i = MyClass()
print(i.a)
# Output: 16
Python Iterators
i = iter(x)
# Output:
print(next(i)) Albert
print(next(i)) Alan
print(next(i)) Joseph
x = "ALAN"
# Output:
i = iter(x)
A
print(next(i))
L
print(next(i)) A
print(next(i)) N
print(next(i))
799
x = "ALAN"
# Output:
for i in x:
A
print(i)
L
Python Math
15
print (math.acosh(5)) # Output: 2.2924316695611777
35
# prints the arc sine value of 0.44
# Output: 2.0
import math
800
import math
print(math.factorial(4)) # Output: 24
801
import math
import math
802
import math
x=9
import math
i=3
print(math.ldexp(9, 3))
print(x*(2**i))
Output:
72.0
import math
Output:
print(math.trunc(5.55)) 5
print(math.trunc(6.36)) 6
print(math.trunc(-100.78)) -100
import math
803
import math
Perpendicular = 20
Base = 10
import math
import math
804
Math Constants
import math
print (math.e)
print (math.inf)
print (-math.inf)
print (math.pi)
print (math.tau)
Output:
2.718281828459045
inf
-inf
3.141592653589793
6.283185307179586
805
Python JSON
import json
b = json.loads(a)
print(b["name"])
# Output: David
import json
print(json.dumps(a))
import json
print(json.dumps(a))
# checks if the string 'x' starts with "Albert" and ends with "German"
i = re.search("^Albert.*German$", x)
Output:
if i:
Wow! We've found a match!
print("Wow! We've found a match!")
else:
print("No match")
806
import re
# checks if the string 'x' starts with "Albert" and ends with "German"
i = re.findall("^Albert.*German$", x)
if i: Output:
else:
print("No match")
import re
print(re.split("\s", x))
import re
Output:
807
import re
# prints all lower case characters alphabetically between "a" and "e"
print(re.findall("[a-e]", x))
import re
# prints all upper case characters alphabetically between "a" and "e"
print(re.findall("[A-E]", x))
import re
x = "1905 Papers"
print(re.findall("\d", x))
import re
x = "albert einstein"
808
import re
x = "albert einstein"
import re
x = "albert einstein"
import re
x = "alan"
y = "james"
import re
y = re.findall("was|albert", x)
print(y)
Output:
if y:
['was']
print("Wow! We've found a match!")
Wow! We've found a match!
else:
print("No match")
809
import re
y = re.findall("[ags]", x)
print(y)
if y:
import re
y = re.findall("[a-c]", x)
print(y)
if y:
810
import re
x = "1905 Papers"
y = re.findall("[0-9]", x)
print(y)
if y:
Output:
print("Wow! We've found a match!")
['1', '9', '0', '5']
else:
Wow! We've found a match!
print("No match")
import re
x = "a+b+c"
y = re.findall("[+]", x)
print(y)
Output:
if y:
['+', '+']
print("Wow! We've found a match!")
Wow! We've found a match!
else:
print("No match")
811
Python If ... Else
x = 25
y= 50
x = 55
if y > x:
y = 25
print("x < y")
if y > x:
# Output: x < y
print("y>x")
else:
x = 25
print("x≠y")
y = 25
# Output: x≠y
if x > y:
elif x == y:
x = 55
print("x=y")
y = 25
# Output: x=y
if y < x: print("y<x")
# Output: y<x
x = 55
y = 25
if y > x:
x = 55
print("y>x")
y = 25
elif x == y:
print("X") if y > x else print("Y")
print("x=y")
# Output: Y
else:
print("x>y")
# Output: x>y
812
x = 25
y = 25
# Output: =
x = 50
y = 25
z = 100
x = 100
y = 50
z = 200
if x > y or x > z:
Python Loops
for i in x: Output:
print(i) C++
if i == "Java":
Java
break
813
x = ["C++", "Java", "Python"]
for i in x:
Output:
if i == "Java":
C++
break
print(i)
for i in x: Output:
if i == "Java": C++
continue Python
print(i)
for i in range(4):
814
i = ["Albert", "Alan"]
Output:
u = ["Engineer", "Doctor"]
Albert Engineer
for a in i:
Albert Doctor
for b in u: Alan Engineer
pass
x = 1
x = 1
while x < 3: Output:
while x < 3:
print(x) 1
print(x)
x += 1 2
x += 1
Output: x is no longer less than 3
else:
1
print("x is no longer less than 3")
2
x = 0
x = 0
while x < 4: Output: while x < 4:
x += 1 Output:
1 x += 1
if x == 2: 1
3 if x == 2:
continue
4 break
print(x)
print(x)
815
Python User Input
x = input("Enter username:")
Enter username:
print("Username is: " + x)
If you enter the word "ram"
print(i)
except:
print(i)
except NameError:
except:
816
try: # would not generate any error
print("Albert")
Output:
except:
Albert
print("Something went incorrect")
Nothing went incorrect
else:
if i < 0:
year = 1905
x = "{name} Einstein's {year} Papers."
name = "Einstein's" print(x.format(name = "Albert", year = "1905"))
print(x.format(year, name))
i = 15
817
x = True
x = False
def myfunc():
print("Albert Einstein")
if __name__ == '__main__':
myfunc()
import sys
A new file is created with name '1.txt' with following contents:
sys.stdout = open('1.txt','wt')
Albert Einstein
print("Albert Einstein")
Alan Turing
print("Alan Turing")
Albert Einstein
Alan Turing
n = [2, 5, 7, 17]
Output:
a = map(lambda i: i%2, n)
0
for x in a:
1
print(x)
1
818
months = ['jan', 'feb', 'mar', 'april', 'may', 'june']
for i in x:
print(i)
# Output:
jan
feb
mar
may
print((8-3)*(2-(1+1))) # Output: 0
print ("xyz" > "") # Output: True
x = [1,2,3,4]
print(x[3]) # Output: 4
a = [11,12]
x = '+'.join(str(i) for i in a)
b = [21,22]
y = '*'.join(str(u) for u in b)
819
x = ['albert', 'alan', 'james', 'mary', 'peter', 'john']
import platform
Python Datetime
import time;
x = time.asctime(time.localtime(time.time()))
820
import datetime
i = datetime.datetime.now()
print(i.strftime("%w")) # Output: 4
print(i.strftime("%d")) # Output: 23
print(i.strftime("%m")) # Output: 06
821
import datetime
i = datetime.datetime.now()
print(i.strftime("%M")) # Output: 37
print(i.strftime("%S")) # Output: 10
class Science:
self.x = x
self.y = y
self.z = z
print(vars(Science()))
822
import statistics
import random
print(random.choice(x)) # Output: C
823
import random
# prints a list that contains any 2 of the items from the list 'x'
import random
import random
# prints a random number between and included 10 and 30 but most likely closer to 15
import cmath
824
Python NumPy
import numpy as np
import numpy
x = np.array([13, 9, 11, 15])
x = numpy.array([50, 100, 150, 200])
print(np.sort(x))
print(x) # Output: [ 50 100 150 200] # Output: [ 9 11 13 15]
import numpy as np
import numpy as np
import numpy as np
# splits the array 'x' into 3 parts
x = np.array([50, 100, 150, 200])
x = np.array([51, 52, 53, 54, 55, 56])
print(x[1]) # Output: 100 print(np.array_split(x, 3))
print(x[2] + x[3]) # Output: 350 # Output: [array([51, 52]), array([53, 54]), array([55, 56])]
import numpy as np
import numpy as np
825
import numpy as np
import numpy as np
x = np.array([[23, 22, 24], [25, 20, 21]])
x = np.array([31, 30, 29, 28, 27])
print(np.sort(x))
i = x.view()
# Output: x[0] = 32
[20 21 25]]
import numpy as np
import numpy as np
x = np.array([31, 32, 33, 34, 35, 36, 37])
x = np.array(['albert', 'james', 'mary'])
print(x[1:5]) # Output: [32 33 34 35]
y = np.array([41, 42, 43, 44])
print(x[4:]) # Output: [35 36 37]
# prints the data type of arrays 'x' and 'y'
print(x[:4]) # Output: [31 32 33 34]
print(x.dtype) # Output: <U6
print(x[-3:-1]) # Output: [35 36]
print(y.dtype) # Output: int64
print(x[1:5:2]) # Output: [32 34]
import numpy as np
x = np.array([[31, 32, 33, 34, 35], [36, 37, 38, 39, 40]])
import numpy as np
Output:
x = np.array([21, 22, 23])
print(np.concatenate((x, y)))
826
Python code to print the current working directory:
import os
import os
os.mkdir(path = y)
import os
x = os.getcwd()
y = x + "/myfiles"
Output:
os.mkdir(path = y)
Current working directory: C:\Users\Manju
# prints the current working directory
New working directory: C:\Users\Manju\myfiles
print("Current working directory: ", os.getcwd())
# change our current working directory to the newly created directory 'myfiles'
os.chdir(y)
# verify that our working directory has been changed using getcwd()
827
import os
x = os.getcwd()
# list all the files and directories present in the current working directory
print(os.listdir(path = x))
import os
x = os.getcwd()
y = "123.txt"
Set the path of the 123.txt file that we are going to delete
i = x + "/" + y
# list all the files and directories present in the current working directory
os.remove(path = i)
# list all the files and directories present in the current working directory
828
Pandas Series
import pandas as pd
print(x)
# Output:
1905 Papers 25 33
1915 Papers 47 89
import pandas as pd
1 72 # Output: 12
2 22
dtype: int64
import pandas as pd
print(y["b"]) # Output: 72
829
import pandas as pd
import pandas as pd
y = pd.Series(x, index = ["a", "b", "c"])
months = {"jan": 31, "feb": 28, "mar": 31}
print(y) print(pd.Series(months))
# Output: Output:
a 12 jan 31
b 72 feb 28
mar 31
c 22
dtype: int64
dtype: int64
import pandas as pd
x = { months days
0 1 31
"months": [1, 2, 3],
1 2 28
"days": [31, 28, 31]
2 3 31
}
print(pd.DataFrame(x))
print(x)
830
# creates a list of the first letters of every word in the given string
# check if the length of a particular word in the given string is odd or even
x = "Albert Einstein"
for i in x.split():
if len(i)%2 == 0:
print("The length of the word " + i + " is even" + " because it has "+ str(len(i)) + " characters")
elif len(i)%2 == 1:
print("The length of the word " + i + " is odd" + " because it has "+ str(len(i)) + " characters")
Output:
x = [11,12,[13,14,'Alan']]
x[2][2] = 'Albert'
831
# display the size of each item in the array
x = "Galileo Galilei"
import numpy as np
for i in x:
x = np.array([[11,12,13]]) if i == "G":
print(i)
else:
# display the data type of each item in the array
pass
import numpy as np
# Output:
x = np.array([[11,12,13]]) G
import numpy as np
# prints 6 values which are evenly spaced over the given interval 6-10
import numpy as np
x = np.array([[11,12,50],[20,25,8]])
Output:
y = np.array([[15,16,1],[32, 39, 35]])
[[11 12 50]
print(np.vstack((x, y)))
[20 25 8]
[15 16 1]
print(np.hstack((x, y)))
[32 39 35]]
Output:
[[11 12 50 15 16 1]
[20 25 8 32 39 35]]
832
11 12
11 12 13
13 14
14 15 16
15 16 reshape() (3 × 2)
(2 × 3)
import numpy as np
x = np.array([[11,12],[13,14],[15,16]])
"""
print(np.dot(2,4)) # Output: 8
[[11 12]
[13 14]
[15 16]]
"""
[[11 12 13]
[14 15 16]]
print('Albert %s' %'Einstein') # Output: Albert Einstein
833
a=3
for x in range(a):
print('+'*(a-x-1) + '*'*(2*x+1)+'+'*(a-x-1))
# Output:
x=21
++*++
if sum(map(int, str(x))) % 2:
+***+
print("odd")
***** else:
print("even")
x=a-1
while x>-1:
print('+'*(a-x-1) + '*'*(2*x+1)+'@'*(a-x-1))
x=x-1
# Output:
***
+*@
x=5
print(i)
# Output:
834
x="Einstein Albert"
print(x[2][1]) x = "15"
# Output: 16
if x.isdigit():
print("Digit")
x=3
else:
for a in range(0, x, int(x**0.5)):
print(a) print("String")
for i in x:
x="NUN"
print(i)
# convert the string 'NUN' to lower case
# Output:
# check whether the string is a palindrome or not
1
# if it is palindrome print 1 else 0
2
print(int(x.lower()==x.lower()[::-1])) # Output: 1
835
x = [11, 13, 12, 12, 13, 14, 15, 12]
i = []
Output:
for a in x:
[11]
if a not in i:
[11, 13]
i.append(a)
[11, 13, 12]
x = "15"
x = "Albert"
if x.isnumeric():
if x.isnumeric():
print("Integer")
print("Integer")
else:
else:
print("String")
print("String")
# Output: Integer
# Output: String
a = "john"
i = ""
x = "michaeljohn"
for x in a:
print(x[0].upper() + x[1:7] + x[7].upper() + x[8:])
i = x + i
# Output: MichaelJohn
print(i)
# Output:
hoj
nhoj
836
a = [11, 12, 13, 14]
print(sum(x)) for i in a:
x += i
print(x)
Output:
50
x = [18,12,13,15,14,17]
x = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
# sort the list in ascending order
print(x[1 : : 2]) # Output: [12, 14, 16, 18, 20]
x.sort()
print(x[-2]) # Output: 17
print(x[1]) # Output: 13
837
x = [19, 15, 'Papers']
for a in x:
myfunc(x)
import pandas as pd
import pandas as pd
print(pd.DataFrame())
if pd.DataFrame().empty:
Output:
print('Empty DataFrame')
Empty DataFrame
else:
Columns: []
print('DataFrame is not empty')
Index: []
# Output: Empty DataFrame
import pandas as pd
print('Empty DataFrame')
Output:
else:
DataFrame is not empty
print('DataFrame is not empty')
838
class Relativity:
year = 1905
physicist = Relativity()
Output:
Albert Einstein
name = getattr(physicist, 'name')
1905
print(name)
print(year)
i = 'print("Albert Einstein")\nprint("Newton")'
839
class Science:
Relativity = 'E=mcsquared'
subject = 'Relativity'
object = Science
print(f'Does the object {object} has attribute named "{subject}"? \n Ans. {result}')
Output:
Ans. True
class Science:
Relativity = 'E=mcsquared'
subject = 'Gravitation'
object = Science
print(f'Does the object {object} has attribute named "{subject}"? \n Ans. {result}')
Output:
Ans. False
840
import numpy as np
# [-25 -10 -5] because (25-50) = -25, (15-25) = -10, and (10-15) = -5
import numpy as np
# [15 5] because:
import numpy as np
# 11 × 12 × 13 × 14 × 15 × 16 × 17 × 18 = 1764322560
import numpy as np
841
import pandas as pd
# Output:
names is_Biologist
0 Einstein False
1 Hawking False
2 Planck False
3 Darwin True
4 Mendel True
import numpy as np
def myfunc():
842
def myFunc(*argv):
# Fibonacci sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 . . .
for i in argv:
# Python program to get the first 5 Fibonacci numbers
print(i) x, y = 0, 1
Output:
myFunc('Albert', 'Einstein') for i in range(0, 5):
0
print(x)
# Output:
x, y = y, x + y 1
Albert
1
Einstein
2
x = np.array([2,6,5]) x = np.array([2,6,5])
y = np.array([4,12,6]) y = np.array([4,12,6])
a = 0 a = 0
for i in z: for i in z:
a = a + 1 a = a + 1
Output: Output:
0: 6 0: 13
1: 18 1: 22
2: 11
843
def myFunc(**kwargs):
for x, y in kwargs.items():
myFunc(Name = 'Albert Einstein', Born = '14 March 1879', Died = '18 April 1955')
Output:
a = [[]]*6
Name = Albert Einstein
a[0].append(3)
Born = 14 March 1879
def myfunc(i):
months = ['jan','feb','mar','apr','may','jun','jul']
yield months[i]
Output:
yield months[i+1]
jan
x = myfunc(0)
feb
print(next(x))
print(next(x))
def myfunc(i):
months = ['jan','feb','mar','apr','may','jun','jul']
yield months[i]
x = myfunc(0) jan
print(next(x))
mar
print(next(x))
844
Output:
plt.bar(a,b)
200
plt.show()
100
0
X Y Z
Output:
plt.show()
100
0
X Y Z
845
Output:
import numpy as np
b = np.array([4, 7, 3])
plt.barh(a, b)
Y
plt.show()
0 1 2 3 4 5 6 7 8
846
Machine Learning Data Science
Benford's Law:
The probability of a first digit being ' x ' is: P(x) = log10(1 + 1/x)
For example:
Lotka's law
(Inverse square law of scientific productivity)
publications
847
The SQL commands are mainly categorized into 4 categories:
SQL Operators
SELECT 60 + 40; 60 + 40
Output 100
SELECT 60 - 40; 60 - 40
20
SELECT 60 * 40; 60 * 40
2400
SELECT 60 / 40; 60 / 40
1.5000
SELECT 60 % 40; 60 % 40
20
848
• Requirements Gathering
• Software Design
• Implementation Three phases are often taken
Agile methodology
• Testing to build a business strategy:
• Deployment • Analysis
• Maintenance
• Decision
• Implementation
Lean development:
• Build a focus on system integrity and the development sequence has to be perfected enough to be able to delete
849
Design thinking + Lean Development + Agile Development = Project success
Assist the software development process where multiple developers make small, frequent changes
to code. The software is tested immediately after each change is made. With each change, code is
built and tested. If the test is passed, the build is tested for deployment. If the deployment is
successful, the code is pushed to production. This code change, build, test, and deploy is a
continuous process and hence the name continuous integration continuous deployment.
Assist the testing of the software at every stage of the software development life cycle.
850
Puppet, Chef, Ansible : Configuration Management and Deployment tools
Automate administration tasks, configure multiple servers at a time − without any user
intervention and gives software team the power to deploy multi-tier applications as fast as
possible.
Assist the software team to detect application performance issues, identify their cause and implement a
solution before the issue leads to unplanned application downtime and lost revenue.
Assist the process of packaging a software application along with its required libraries, frameworks and
configuration files together so that it runs quickly and reliably in various computing environments.
851
Regression Testing → performed to ensure that new product version still works after the
new changes have been made.
Commit changes to
the source code
Developer
Developer
Shared repository Pull changes made in the
source code from the shared
repository
Developer
Commit changes to Jenkins
the source code
Send Data
852
AWS Services: AWS EC2
Compute
Storage
A part of the cloud computing infrastructure from Amazon.com that offers
Networking
secure, scalable compute capability
Monitoring
Databases
Security AWS Lambda
AWS Elastic Beanstalk A serverless compute service that makes it easier to implement the code
without worrying about setting up or managing servers
AWS Lightsail
An AWS service that is
simple to use and creates
the foundation for
An AWS service that gives application developers access to a customizable
developing and scaling web
virtual private server (VPS) and a number of simple-to-use tools for data
applications
storage, code execution and the creation of websites or web-based applications
853
import sys
import os
path = 'C:/Users/Manju'
import os
path = 'C:/Users/Manju'
import os
import os
import os
854
import sys
import glob
print(glob.glob('*.txt'))
import os
print(os.listdir(os.curdir))
import time
print('Einsteinian %d and [%s] papers' % (1905, 1915)) # Output: Einsteinian 1905 and [1915] papers
print(open('1.txt').read())
x = open('output.txt', 'r').read()
y = open(r'C:\Users\Manju\output.txt', 'r').read()
855
import html.parser
import re
print(re.split('(--)|(==)', 'xx--yy==zz')) # Output: ['xx', '--', None, 'yy', None, '==', 'zz']
x = {}
6.283185307179586
exec('a = 100', x, x) x = 1
6.283185307179586
exec('c = a + b', x, x) for i in range(3):
6.283185307179586
print(x['c']) # Output: 121 print(math.pi*x*(1+x))
856
x="Albert"
y=5
print(x[y-1]) # Output: r
print(x)
""" 6
print(x.center(50)) 3
""" 9
Output:
print('Alan', end='')
Albert Einstein grew up in Munich
print('Turing') # Output: AlanTuring
"""
for x in range(3):
Alan (1)
Alan (2)
857
print((3 < 7) and (7 < 9)) # Output: True
print(x)
True and (7 < 9) # Output:
3
True and True 2
1
True 0
def myfunc():
Output:
print('Alan')
Alan
myfunc()
Alan
myfunc()
Alan
myfunc()
def myfunc(x):
Output:
print('Albert, ' + x)
Albert, 1905
myfunc('1905')
Albert, 1915
myfunc('1915')
Albert, 1955
myfunc('1955')
print('Albert Einstein')
def myfunc(x):
Output:
indent = 3 # 3 spaces to indent
return 55 / x
Albert Einstein
print(' ' * indent, end='')
print(myfunc(5)) # Output: 11.0 Albert Einstein
print('Albert Einstein')
858
x = [['alan', 'albert'], [12, 22, 32, 42, 62]]
# Output: True
for a in range(len(x)):
x += 'Einstein' x *= 2
import random
x = ['c', 'b', 'C', 'B']
if random.randint(0, 1) == 0:
x.sort(key=str.lower)
print("random number is 0")
print(x) # Output: ['b', 'B', 'c', 'C']
else:
859
JavaScript
Did you know?
Designed by Brendan Eich of Netscape initially; others have also contributed to the ECMAScript standard
.js
Filename Brendan Eich
.cjs
extensions
.mjs Creator of JavaScript
Website www.ecma-international.org/publications-and-standards/standards/ecma-262/
Major implementations
Influenced by
860
Java, Scheme Self, AWK, HyperTalk
Influenced
Designed by an American technologist and co-founder of the Mozilla project, the Mozilla
Foundation, and the Mozilla Corporation "Brendan Eich" and it was developed under
the name Mocha, the language was officially called LiveScript when it first shipped in beta
releases of Netscape Navigator 2.0 in September 1995, but it was renamed JavaScript
primarily used to design interactive websites with dynamic content and perform functions
that the HTML cannot do, because of its reliability, simplicity and easy to understand,
easy to use, write, modify and debug and quick to learn.
The primary language used in web design is HTML. In addition to HTML, CSS is employed to further
enhance web page appearance. HTML and JavaScript are combined to build dynamic websites.
Advantages of JavaScript:
861
Syntax:
Tag used to incorporate an executable
client side scripting language such as
JavaScript into an HTML page
<script>
</script>
Inserted in the <body> or in the <head>
section of an HTML document or in both
<script>
// Single-line Comment
*/
// Display the text "Albert Einstein" on the console screen using document.write() method
// Display the result "31" on the console screen using document.write() method
document.write(15 + 16);
</script>
862
<script>
// Display the text "Albert Einstein" on the console screen using console.log() method
console.log('Albert Einstein');
console.log("Albert Einstein");
// Display the result "31" on the console screen using console.log() method
console.log(15 + 16);
</script>
<script>
let x = 15;
let y = 12;
// Declare z, give it the value of "x + y" using the assignment operator "="
let z = x + y; The addition operator (+) adds 2 numbers 'x' and 'y'
</script>
863
<script>
let x = 15;
let y = 12;
let z = x - y;
document.write(z); // Output: 3
</script>
The subtraction operator (-) subtract the number "y" from the number "x"
<script>
let x = 15;
let y = 12;
let z = x * y;
</script>
<script>
let x = 6;
let y = 2;
let z = x / y;
document.write(z); // Output: 3
</script>
The division operator (/) divides the number 'x' by the number 'y'
864
<script>
let x = 7;
let y = 2;
let z = x % y;
document.write(z); // Output: 1
</script>
<script>
let x = 7;
x++;
let z = x;
document.write(z); // Output: 8
</script>
<script>
let x = 7;
x--;
let z = x;
document.write(z); // Output: 6
</script>
865
<script>
let x = 4;
let z = x ** 3;
document.write(z); // Output: 64
</script>
The exponentiation operator (**) raises the number "x" to the power of 3
<script>
let x = 4;
let z = Math.pow(x,3);
document.write(z); // Output: 64
</script>
<script>
let x = 50 + 50 * 3;
</script>
866
<!DOCTYPE html> <!-- Identifies this document as being an HTML5 document -->
<!--
The HTML document contains a <p> element that has the id attribute with the value "add".
-->
document.getElementById("add").innerHTML = 15 + 16;
</body>
</html>
This program display the computed result "31" on the console screen
Output:
31
867
var x = 15;
The "var" keyword has been used to
var y = 26;
declare the variables x, y and z
var z = x * y;
let x = 15;
The "let" keyword has been used to
let y = 26;
declare the variables x, y and z
let z = x * y;
x = 15;
The no keyword has been used to declare
y = 26;
the variables x, y and z
z = x * y;
868
<script>
console.log(x+y);
// Output: 12.25
</script>
<script>
x = 549e5;
x and y are undeclared variables
y = 549e-5;
</script>
<script>
x = 2;
y = 3;
console.log(x+y); // Output: 5
x = 1905;
y = " Papers";
</script>
869
<script>
<script>
x = 5; console.log("Albert \\ John");
</script>
<script>
x = 10;
y = 9;
z = "15";
</script>
<script>
</script>
870
<script>
<script>
x = "6"; // numeric string
console.log("Albert \"1905\" Papers");
y = "2"; // numeric string
// Output: Albert "1905" Papers
console.log(x * y); // Output: 12
console.log('Alan\'s Papers');
</script> // Output: Alan's Papers
</script>
<script>
</script>
<script>
</script>
871
<script>
NaN is the result of dividing a
x = "6"; // numeric string
number by a non-numeric string
y = "Albert"; // non-numeric string
</script>
<script>
x = "6";
y = "Albert";
</script>
<script>
y = NaN; </script>
z = "5";
</script>
<script>
x = 25; // x is a number
</script>
x and y are equal
872
<script>
x = 25; // x is a number
</script>
<script>
<script>
console.log("Welcome to 'Alberta'");
// Display the length of a string 'Albert'
// Output: Welcome to 'Alberta'
x = "Albert";
console.log('Welcome to "Alberta"');
console.log(x.length); // Output: 6
// Output: Welcome to "Alberta"
</script> </script>
<script>
x = "Albert"; // x is a string
</script>
873
console.log("Albert
Error: Unterminated string literal
Einstein");
console.log("Albert \
No Error
Einstein");
Output: Albert Einstein
console.log("Albert "
+ No Error
<script>
x = "Albert"; // x is a string
</script>
874
<script>
x = new String("Albert");
y = new String("Albert");
</script>
JavaScript objects
console.log(x); // Output: 20
</script> The object "z" in the example above has 2 properties: Name
and Country and 2 property values: Albert and Germany
875
<script>
</script>
Polyfill:
let y = 35;
let z = 56;
</script>
<script>
</script>
876
<script>
</script>
<script>
var x = "Albert";
var y = "Einstein";
</script>
<script>
x += "Einstein";
console.log(x.Age); // Output: 56
</script>
877
<script>
console.log(x["Age"]); // Output: 56
</script>
The object "x" in the example above has 3 properties: Name, Country
and Age and 3 property values: Albert, Germany and 56
<script>
var x = 20;
x += 15; // x = x + 15
console.log(x); // Output: 35
var x = 20;
x -= 15; // x = x - 15
console.log(x); // Output: 5
</script>
878
<script>
var x = 20;
x *= 15; // x = x * 15
var x = 20;
x *= 15; // x = x / 15
</script>
<script>
var x = 21;
x %= 2; // x = x % 2
var x = 4;
x **= 2; // x = x ** 2
console.log(x); // Output: 16
</script>
879
<script>
/*
*/
function add(x, y) {
return x + y;
</script>
<script>
function mult(x, y) {
</script>
880
<script>
</script>
<script>
</script>
<script>
console.log(x.replace("Albert", "Elsa"));
console.log(x.replace(/Albert/g, "Elsa"));
</script>
<script>
var x = "albert";
console.log(x.toUpperCase());
// Output: ALBERT
</script>
881
<script>
var x = "ALBERT";
console.log(x.toLowerCase());
// Output: albert
</script>
<script>
</script>
<script>
console.log(x.trim());
// Output: Albert
</script>
882
<script>
console.log(x.trimStart());
console.log(x.trimEnd());
</script>
0 1 2 3 4 5 6 7
E i n s t e i n
<script>
/*
*/
var x = "Einstein";
</script>
883
<script>
var x = "16";
/*
*/
</script>
<script>
var x = 16;
var y = x.toString();
</script>
884
0 1 2 3 4 5 6 7
E i n s t e i n
<script>
let x= "Einstein";
console.log(x[0]); // Output: E
console.log(x[1]); // Output: i
console.log(x[2]); // Output: n
console.log(x[3]); // Output: s
console.log(x[4]); // Output: t
console.log(x[5]); // Output: e
console.log(x[6]); // Output: i
console.log(x[7]); // Output: n
</script>
<script>
/*
*/
</script>
885
<script>
</script>
<script>
var x = "Sleep well! What is up? It is Albert here. Albert and I are connected.";
console.log(x.split(/[!,?,.]/));
</script>
[ 'Sleep well',
'' ]
<script>
var x = "Sleep well! What is up? It is Albert here. Albert and I are connected.";
'!',
</script>
' What is up',
'?',
'.',
'' ]
886
<script>
/*
*/
console.log(x.indexOf("Einstein")); // Output: 5
</script>
<script>
/*
*/
console.log(x.lastIndexOf("Einstein")); // Output: 25
</script>
887
<script>
/*
*/
console.log(x.search("Einstein")); // Output: 5
</script>
<script>
/*
Search a string "Elsa Einstein was Albert Einstein's wife" for "ein"
*/
</script>
888
<script>
console.log(x.match(/ein/gi));
</script>
<script>
/*
*/
</script>
889
<script>
/*
Check if a string
*/
</script>
<script>
/*
*/
</script>
890
<script>
/*
*/
</script>
<script>
var x = 1915;
// 120 + 42 = 162
// console.log((162).toString());
</script>
891
<script>
/*
*/
Output:
let x =
Elsa Einstein
`Elsa Einstein
was
was
Albert Einstein's
Albert Einstein's
wife`; wife
console.log(x);
</script>
<script>
let x = "Mathison";
let y = "Turing";
</script>
892
<script>
var x = 5.496;
</script>
<script>
/*
*/
var x = 5.496;
console.log(x.toFixed(0)); // Output: 5
</script>
893
<script>
/*
*/
var x = 5.496;
</script>
<script>
console.log(Number.MAX_VALUE);
// Output: 1.7976931348623157e+308
console.log(Number.MIN_VALUE);
// Output: 5e-324
</script>
894
<script>
</script>
<script>
console.log(Number(true)); // Output: 1
console.log(Number(false)); // Output: 0
console.log(Number("54")); // Output: 54
console.log(Number("54.96")); // Output: 54
</script>
Not a Number or NaN is returned if the
converted to numbers
895
<script>
console.log(parseInt("54.96")); // Output: 54
</script>
<script>
x = [];
x[0]= "Apple";
x[1]= "Orange";
x[2]= "Mango";
</script>
<script>
</script>
896
<script>
x[0] = "Grapes";
</script>
<script>
console.log(x.length); // Output: 3
Obtaining the data type
</script>
of an object
<script>
</script>
Setting the data type of
<script> an object
x = ["Apple", "Orange", "Mango"];
x.push("Grapes");
</script>
897
<script>
x[x.length] = "Grapes";
</script>
<script>
x[6] = "Grapes";
console.log(x);
</script>
<script>
console.log(x);
</script>
Indentation:
898
<script>
</script>
<script>
</script>
<script>
/*
</script>
899
<script>
// All array elements are combined into a string by the join() method
</script>
<script>
names.pop();
</script>
<script>
*/
names.unshift("Mary");
</script>
900
<script>
delete names[0];
console.log(names);
</script>
<script>
x = ["Apple", "Orange"];
console.log(x.concat(y));
</script>
<script> [ 'Apple',
'Grapes',
'Raspberries',
console.log(x.concat(y, z));
'Banana' ]
</script>
901
<script>
x = ["Apple", "Orange"];
console.log(x.concat("Mango"));
</script>
<script>
console.log(x);
</script>
902
<script>
console.log(x);
</script>
<script>
console.log(x.toString());
// Output: Apple,Orange,Mango,Pear
</script>
<script>
console.log(x.sort());
</script>
903
<script>
console.log(x);
console.log(x);
</script>
<script>
</script>
904
<script>
// Output: 2.718281828459045
console.log(Math.PI); // Displays PI
// Output: 3.1415926535897935
// Output: 1.4142135623730951
// Output: 0.7071067811865476
// Output: 0.6931471805599453
// Output: 2.302585092994046
// Output: 1.4426950408889634
// Output: 0.4342944819032518
</script>
905
<script>
// Math.floor() returns the value of "x" rounded down to its nearest integer
x = 4.6;
console.log(Math.floor(x));
// Output: 4
console.log(Math.ceil(x));
// Output: 5
</script>
<script>
x = 4.6;
console.log(Math.trunc(x)); // Output: 4
y = -4.6;
console.log(Math.trunc(y)); // Output: -4
</script>
906
<script>
console.log(Math.sqrt(16)); // Output: 4
console.log(Math.log2(16)); // Output: 4
console.log(Math.log10(100)); // Output: 2
</script>
907
<script>
</script>
<script>
console.log(Math.floor(Math.random() * 11));
console.log(Math.floor(Math.random() * 101));
</script>
<script>
</script>
908
<script>
var x = 19;
</script>
If the variable "x" is a value below 18, then
x<18 is displayed, otherwise x>18 is displayed
<script>
var y=6;
if(x>y) {
} else {
</script>
Currying
909
<script>
var x=4;
JavaScript else-if statement
var y=6;
var z=12;
if(x>y&&x>z) {
} else if (y>x&&y>z) {
} else {
</script>
<script> Output:
JavaScript for loop
var i; 1
2
for(i=1; i<=10; i++)
3
document.write(i);
4
</script>
5
10
910
<script> Output:
<script>
var i=1; 1
var i=1;
2
do {
while(i<=10) {
3
document.write(i++);
4 console.log(i++);
} while(i<=10)
5 }
</script> 6 </script>
7
10
<script>
Output:
x = [85, 6, 9, 36, 3];
85
for(i in x) {
6
console.log(x[i]);
9
} 36
</script> 3
JavaScript Hoisting
911
<script>
var ch ='2';
JavaScript Switch case
switch(ch) {
case '1':
document.write("Red");
break;
case '2':
document.write("White");
break;
case '3':
Output:
document.write("Yellow");
White
break;
case '4':
document.write("Green");
break;
default:
document.write("Error");
break;
</script>
<script>
var x = 6;
var y = 2;
alert("Albert");
</script>
912
<!DOCTYPE html>
<html>
<head>
<script>
function addNumbers() {
var x = parseInt(document.getElementById("value1").value);
var y = parseInt(document.getElementById("value2").value);
var z = document.getElementById("answer");
z.value = x + y; value1 =
}
value2 =
</script>
Click here
</head>
Answer =
<body>
</body>
</html>
913
The above program demonstrates how to get two inputs from the user (i.e., value1 and value2) and
have a button (i.e., Click here) on the page to call a function:
addNumbers()
to process the inputs and output the answer on the console screen.
var x = parseInt(document.getElementById("value1").value);
parseInt(document.getElementById("value1").value)
var y = parseInt(document.getElementById("value2").value);
parseInt(document.getElementById("value2").value)
914
parseInt(document.getElementById("value2").value) → get the integer value for "y"
entered in the input field which is defined with id "value2"
After entering the values for "x" and "y" in the input fields – if we click on the button
Click here
var z = document.getElementById("answer");
Statements
z.value = x + y;
are executed − i.e., the entered values for "x" and "y" are added and the answer is entered in the input
field which is defined with id "answer".
<script>
Output:
if(i==5) {
1
break;
2
}
3
console.log(i);
4
</script>
915
<script> 1
if (i==5) { 3
continue; 4
} Output 6
7
console.log(i);
8
}
9
</script>
10
<script>
x = "Alan";
Output:
for(i of x) { A
console.log(i); l
} a
</script> n
<script>
916
<script>
x = new Set(["A","B","C"]);
Output:
for(i of x) {
A
console.log(i);
B
} C
</script>
<script>
x = new Map([
["Albert", 56],
Output:
["John", 85],
[ 'Albert', 56 ]
["Elsa", 45]
[ 'John', 85 ]
]);
[ 'Elsa', 45 ]
for (i of x) {
console.log(i);
</script>
917
<script>
x = new Set();
x.add("A");
x.add("B");
x.add("C");
</script>
<script>
x = new Set();
// Create Variables
var a = "A";
var b = "B";
var c = "C";
x.add(a);
x.add(b);
x.add(c);
</script>
918
<script>
x = new Map();
x.set("Albert", 56);
x.set("John", 38);
x.set("Elsa", 46);
console.log(x); // Output: Map { 'Albert' => 56, 'John' => 38, 'Elsa' => 46 }
console.log(x.get("Albert")); // Output: 56
console.log(x.size); // Output: 3
x.delete("Albert");
</script>
919
<script>
Prevent us from using undeclared variables
"use strict";
x = 5.496;
</script>
<script>
"use strict";
var x = 5.496;
</script>
<script>
</script>
920
PHP
Preview release 8.0.0 Release Candidate 3 / October 30, 2020; 2 days ago
OS Unix-like, Windows
License PHP License (most of Zend engine under Zend Engine License)
Filename .php , .phtml , .php3 , .php4 , .php5 , .php7 , .phps , .php-s , .pht , .phar
extensions
Website www.php.net
Major implementations
Influenced by
Influenced
921
Hack, JSP, ASP
Lerdorf" in 1994 − as an efficient alternative to other scripting languages like Ruby, Perl and
Microsoft's ASP) is an relatively free (not licensed by a major corporation) popular efficient
server side programming language (and relatively easy one to master and quick to learn) that
carries out common website duties like accepting passwords, authenticating users, and managing
forum posts and guest books. Without PHP Facebook, Yahoo, Google wouldn't have existed.
PHP is a server scripting language that may be used to create dynamic, engaging websites.
PHP Keywords
922
689
PHP Comments
Code:
<?php
/*
This is a
Comments are lines of code that are not executed when
multiple-line
a program is executed and are typically written inside
comment a block of PHP code to describe how the code works.
?>
PHP Variables
Code:
<?php // A PHP script starts with <?php and ends with ?>
$x = 5 /* + 12 */ + 0;
Declaring and assigning values to Variables
$y = 5;
echo $x + $y; # Display the sum of $x and $y
?>
923
689
Code:
<?php
In PHP, a variable starts with the $ sign,
followed by the name of the variable
$txt = "World";
echo "Hello $txt!";
?>
Hello World!
Code: <?php
?>
924
691
PHP $GLOBALS
Code:
Code:
<?php
$x = 7982;
$y = 798.2;
?>
float(798.2)
925
PHP Strings
Code:
<?php
Return the length of the
echo strlen("Hello world!"); string "Hello world!"
?>
12
Code:
<?php
Return the number of words found
echo str_word_count("Alan Turing");
in the string "Alan Turing"
?>
Code:
<?php
Reverse the string "Alan Turing"
echo strrev("Alan Turing");
?>
926
Output on the screen:
gniruT nalA
Code:
<?php
?>
Replace the word "world" in the string
"Hello world!" with "Computer"
Hello Computer!
PHP Numbers
Code:
<?php
$x = 8885;
var_dump(is_int($x));
Check whether a variable is
of type integer or not
$y = 86.85;
var_dump(is_int($y));
$z = 86.85; Output:
927
PHP Math
Code:
<?php
The pi() function returns the value of PI
echo(pi());
?>
3.1415926535898
Code:
<?php
echo(min(0, 150, 30, 20, -8, -200)); # Display the lowest value in a list
echo "\n";
echo(max(0, 150, 30, 20, -8, -200)); # Display the highest value in a list
?>
−200
150
Code:
<?php
The abs() function returns the absolute
echo(abs(−6.27)); (positive) value of a number
?>
928
695
Output on the screen:
6.27
Code:
<?php
?>
Code:
<?php
The round() function rounds a floating-point
echo(round(4.8));
variable to its nearest integer
?>
Code:
<?php
echo(rand(10, 100)); The rand() function generates a random
929
695
93
PHP Constants
Code:
<?php Creating a constant with a case-sensitive name using the define() function
Hello World!
Code:
<?php Creating a constant with a case-insensitive name using the define() function
?> is case-insensitive
Hello World!
930
695
Code:
<?php
define("fruits", [
"Apple",
"Mango", Creating an Array constant using the define() function
"Orange"
]);
echo fruits[1];
?>
Code:
<?php
myfunc();
?>
Hello World!
931
695
PHP Operators
Code:
<?php
// Convert the first character of each word to uppercase
<?php echo ucwords("albert einstein");
# Output: Albert Einstein
?>
$x = 12;
$y = 6;
?>
18
6
2
72
0
932
695
Code:
<?php
$num1=2;
$num2=3;
?>
PHP if Statement
Code:
933
695
<?php
$x = 25;
?>
Albert Einstein
Code:
<?php
$x = 4.5;
Output "x is greater than y" if
$y=5;
$x is greater than $y, and "y is
if($x>$y) {
greater than x" otherwise
echo ("x is greater than y");
} else {
?>
y is greater than x
934
695
PHP else if Statement <?php
Code: /*
Replace the characters "ALBERT" (case-insensitive)
<?php in the string "Albert Einstein" with "Elsa"
*/
$x = 4.5;
echo str_ireplace("ALBERT", "Elsa", "Albert Einstein");
$y = 5; # Output: Elsa Einstein
$z = 6; ?>
else {
?>
<?php
$x = 5496;
# Output: bool(true)
?>
935
695
PHP switch Statement
Code:
<?php
$ch ='3';
echo "Red";
break;
echo "White";
$x = 54.960;
break;
case '3': /*
Prints the value of above integer
echo "Yellow";
variable as a numeric string
break;
*/
case '4':
echo strval($x);
echo "Green";
break;
?>
default:
echo "Error";
break;
?>
Yellow
936
695
PHP Loops
Code:
<?php
$i = 1;
PHP while Loop
while($i <= 10) {
echo "\n $i ";
$i++;
?>
Code:
<?php
$i = 1;
937
695
Output on the screen:
<?php
1 # Repeat the string "Albert" 3 times
2 echo str_repeat("Albert ",3);
3 // Output: Albert Albert Albert
4 ?>
5
6 <?php
7 # Randomly shuffle all characters of a string "Albert"
8 echo str_shuffle("Albert");
9 // Output: eAtrbl
?>
Code:
<?php
<?php
Output on the screen:
8 echo strtoupper("albert");
9 # Output: ALBERT
10
?>
938
695
Code:
PHP foreach Loop
<?php
$fruits = array("Apple", "Mango", "Kiwi", "Orange");
Mango
Kiwi # Convert the first character of "Alan" to lowercase
Code: ?>
<?php
PHP Break
for($x = 0; $x < 6; $x++) {
if($x == 4) {
break;
This program jumps out of the
}
loop when "x" is equal to 4
echo "$x \n";
}
?>
939
695
Output on the screen:
0
1
2
3
Code:
<?php
for($x = 0; $x < 6; $x++) { PHP Continue
if ($x == 4) {
continue;
} This program skips the value of "4"
echo "$x \n";
}
?>
0
1
2
3
5
<?php
$x = "Albert";
Check whether a variable "x" is
var_dump(is_string($x));
of type string or not
# Output: bool(true)
?>
940
695
PHP Functions
Code:
<?php <?php
function addition($a, $b) { function myfunc() {
return $a + $b; echo "Albert Einstein";
} }
?>
PHP Arrays
Code:
<?php
An array stores multiple values
$x = array("Apple", "Orange", "Mango"); in one single variable
echo "I like " . $x[0] . ", " . $x[1] . " and " . $x[2] . " fruits";
?>
941
695
Code:
?>
<?php
# Output: bool(true)
?>
<?php
$x = NULL;
var_dump(is_null($x)); Check whether a variable is NULL or not
# Output: bool(true)
?>
<?php
$x = true; // boolean value
var_dump(is_scalar($x)); # Output: bool(true) Check whether a variable
is a scalar or not
$y = 5; // integer value
var_dump(is_scalar($y)); # Output: bool(true)
?>
942
695
<?php
?>
<?php
echo ord("B");
// Output: 66
?>
<?php
echo($x);
?>
<?php
// Split the string after each character and add "*" after each split
$x = "Alan";
echo chunk_split($x,1,"*");
# Output: A*l*a*n*
?>
943
A system that carries information
between 2 or more entities, in the
Computer network
form of electric signals
Antifragile
Continuous Quality
Response
A methodology of managing
software development projects that
• HTTP: Hypertext Transfer Protocol iteratively emphasizes frequent
• URL: Uniform Resource Locator "http://www.myw3schools.com" releases and incorporates customer
feedback at every stage
• HTML: Hypertext Markup Language
944
Computer vision → Write computer programs that can interpret images
Binary 0 or 1
Octal (0 −7)
Hexadecimal (0 – 9) + (A− F)
Decimal (0 – 9)
Provisioning
• 0 = false = no
The process of setting up IT infrastructure
Booleans • 1 = true = yes
A software testing technique where run time behavior of software application under testing is
examined against predictions made by a model
945
• Requirements analysis
• Design Software Project
• Construction Management
• Testing
The phrase "internet surfing" was coined by a
librarian named Jean Armour Polly in 1992
Self-Service Deployment
Python code:
print("{0:x}".format(144)) # Output: 90
946
Description:
Description: Output:
Description:
Find files that have more than 100 characters (bytes) in them.
Command:
947
Description:
Command:
Description:
Command: • print("{:.3}".format("albert"))
• print("{:5.3}".format("albert"))
find . -type f -mtime -1 -delete
• print("{:>5.3}".format("albert"))
• print("{:^5.3}".format("albert"))
• print("{:*^5.3}".format("albert"))
Description:
alb
alb
Command: alb
alb
*alb*
948
ls -a
Description:
Description:
x="{:{a}{b}{c}}"
print(x.format('john', a='*',b='^',c=5))
print(x.format('john', a='*',b='^',c=6))
ls -r
# Output: *john*
print(x.format('john', a='*',b='<',c=6))
# Output: john**
Description: print(x.format('john', a='*',b='>',c=6))
# Output: **john
Sort Files by File Size.
949
Command:
ls -lS
Description:
Description:
Command:
a=["Alan", "Albert", "John"]
ls --version b=["Alan", "Albert", "John"]
c=["ALAN","ALBERT","JOHN"]
print(a==b) # Output: True
print(a==c) # Output: False
print(a != c) # Output: True
Description:
950
Command: a={100,200,300,400}
b={300,400,500,600}
ls -l /tmp print(a.union(b))
# Output: {100, 200, 300, 400, 500, 600}
print(a|b)
# Output: {100, 200, 300, 400, 500, 600}
Description:
Command:
ls -n
x=(100,200,300,400,500,600)
print(x[2:1000])
# Output: (300, 400, 500, 600)
print(x[1000])
Description: # Output: IndexError: tuple index out of range
Command:
x={100,200,300,400,500,600}
x.remove(300)
print(x) # Output: {100, 200, 400, 500, 600}
x.discard(300)
print(x) # Output: {100, 200, 400, 500, 600}
951
Description:
Command:
Description:
a={100,200,300,400}
b={300,400,500,600}
List directories larger than 20 KB.
print(a.intersection(b))
# Output: {400, 300}
print(a&b)
# Output: {400, 300}
Command:
Description: a={100,200,300,400}
b={300,400,500,600}
print(a.difference(b))
Find empty files and directories.
# Output: {200, 100}
print(a-b)
# Output: {200, 100}
print(b.difference(a))
Command: # Output: {600, 500}
print(b-a)
find ./ -type f -size 0 # Output: {600, 500}
952
Description:
Command:
Description:
List all files modified between 6 and 15 days ago in the home directory.
Command:
953
find /home -type f -mtime +6 -mtime -15
Command:
x=open("1.txt",'w')
Description:
954
Command:
Description:
Find and list files and directories together with their permissions.
Command:
Description:
955
Command:
ls --format=comma
ps -u manju
Description:
x=open("1.txt",'w')
a=["John\n","Mary\n","James\n","Albert"]
x.writelines(a)
Command: print("List of names added to the 1.txt file successfully")
x.close()
!c
John
Mary
1.txt
James
Albert
956
Description:
Command:
dmidecode -t 0
Description:
x=open("1.txt",'r')
i=x.read()
print(i)
Command: x.close()
dmidecode -t 4
# Output:
John
Mary
James
Description: Albert
Command:
# Output:
John
gnome-system-log
Mary
957
Description:
x=open("1.txt",'r')
Identify SSH Client Version. print(x.readline(),end='')
print(x.readline(),end='')
print(x.readline(),end='')
print(x.readline(),end='')
Command: x.close()
ssh -V # Output:
John
Mary
James
Description:
Albert
958
ac -p
Description:
Command:
ac -d manju
import os
# prints all statistics of 1.txt file
print(os.stat("1.txt"))
Description:
Description:
25
2022-06-28 02:20:25.945846
2022-07-08 04:53:18.734652
959
Command:
ps U $USER
Description:
+ • Arithmetic addition
Command: print(22+55) # Output: 77
• String concatenation
df -Tha print('Alb'+'ert') # Output: Albert
* • Multiplication
print(2*5) # Output: 10
• String repetition
Command: import gc
print(gc.isenabled()) # Is Garbage Collector enabled
netstat -tap # Output: True
gc.disable() # Garbage Collector is disabled
print(gc.isenabled()) # Is Garbage Collector enabled
# Output: False
gc.enable() # Garbage Collector is enabled
Description: print(gc.isenabled()) # Is Garbage Collector enabled
# Output: True
960
import re
print(re.sub("[a-z]","#","x9y8z7w6c"))
Command:
# Output: #9#8#7#6#
print(re.subn("[a-z]","#","x9y8z7w6c"))
netstat --statistics --raw
# Output: ('#9#8#7#6#', 5)
# 5: The number of replacements
961
C Exercises
Solution:
#include <stdio.h>
int main() { Modeling Tool
printf("Hello, World!");
A tool for building models
return 0;
}
Solution:
962
#include <stdio.h>
int main() {
int x;
Acyclic Dependencies Principle:
int y;
int sum;
A key strategy for developing the structure of software
systems in such a way that the dependencies between the
printf("Enter a number : \n");
components of the software system do not form a cycle
scanf("%d", &x);
printf("Enter a number : \n");
scanf("%d", &y);
sum = x + y;
printf("Sum of %d + %d = %d", x, y, sum);
return 0;
}
Solution:
Adaptability Quality Attribute:
#include <stdio.h>
int main() { How well and how efficiently a software
int x; system may be modified to work in various
int y;
operational or usage situations with various
int difference;
hardware, software, or other factors
963
printf("Enter a number : \n");
scanf("%d", &x);
printf("Enter a number : \n");
A pattern that appears on a
scanf("%d", &y);
difference = x - y; regular basis is referred to as
Architecture evaluation:
Question 4
Evaluation of a software
architecture using quantitative or
Question: qualitative methods
Solution:
Architectural Decision
#include <stdio.h>
int main() {
int x;
A decision that significantly or sustainably
int y;
affects the software's architecture
int division;
964
printf("Division of %d / %d = %d", x, y, division);
return 0;
}
scanf("%d", &r);
area = PI*r*r;
Circumference = 2*PI*r;
return 0;
965
}
Question:
#include <stdio.h> How well a software application may be utilized by specific users to
int main() { meet specific goals like becoming effective, efficient, risk-free, and
int l; satisfied users of the application in a certain usage environment
int b;
long area;
966
Question 7
The Reusability Principle:
Solution:
#include <stdio.h>
int main() { Coupling:
int h;
int b; A measure of how closely two software
long area; components are connected
Accidental complexity: Difficulties that coders accidentally create for themselves when attempting
to tackle a problem
Essential complexity: How challenging a task is − regardless of our level of expertise, the tools we
utilize, or the innovative and eye-catching architecture pattern we used to address the issue
967
Question 8
Mahout: An Apache open-source framework intended for
the development of machine learning models
Question:
Constraint:
968
Question 9 Installability Quality Attribute:
969
Solution:
How well and how efficiently the functions facilitate the completion
of particular tasks and goals
Question:
Solution:
Functional Correctness Quality Attribute:
#include <stdio.h> How well and how efficiently a software system delivers the
#define PI 3.141592
required level of precision and the accurate results
int main() {
970
printf("Enter length of minor axis: \n");
scanf("%f", &minor); Integrity Quality Attribute:
area = PI * major * minor;
printf("Area of an ellipse = %0.4f", area); How well a software system prevents
Solution:
#include <stdio.h>
#define PI 3.141592 Modifiability Quality Attribute:
int main() {
How well a software application may be updated
int b;
quickly and economically without introducing flaws
971
printf("Volume of Pyramid with Base Area as %d and Height as %d = %f", b, h, volume);
return 0;
int h;
int r;
float volume; Markov chain:
float PI = 3.141592;
A stochastic model that depicts a series of conceivable
printf("Enter the Radius of Cone : \n");
events where each event's likelihood solely depends on
scanf("%d", &r);
the condition obtained in the preceding event
printf("Enter the Height of Cone : \n");
scanf("%d", &h);
volume = 1/3 * PI*r*r*h;
printf("Volume of Cone with Radius as %d and Height as %d = %f", r, h, volume);
return 0;
}
972
Question 14 Operability Quality Attribute:
Solution:
#include <stdio.h>
Open-Close-Principle:
int main() {
973
Solution:
Perfect Forward Secrecy:
#include <stdio.h> A cryptographic protocol's ability to prevent an attacker
int main() {
from obtaining anything about short-term session keys
through the breach of long-term keys
int r1,r2,r3;
float volume;
float PI = 3.141592;
printf("Enter the Radius of the ellipsoid of axis 1 : \n");
scanf("%d", &r1);
printf("Enter the Radius of the ellipsoid of axis 2 : \n");
scanf("%d", &r2);
printf("Enter the Radius of the ellipsoid of axis 3 : \n");
scanf("%d", &r3);
volume = (4/3)*(PI*r1*r2*r3);
printf("Volume of Ellipsoid with (r1,r2,r3) as (%d,%d,%d) = %f",r1,r2,r3,volume);
return 0;
}
974
int main() {
Qualitative evaluation:
Quality attribute:
Question 17
The extent to which a software application has the
desired set of characteristics
Question:
#include <stdio.h> The extent to which a software system can restore its
int main() { desired state and recover any immediately damaged
data in the case of an interruption or failure
int r;
float PI = 3.141592;
float surfacearea;
Markov property:
printf("Enter the Radius of Sphere : \n");
scanf("%d", &r); Future Markov process evolution is
surfacearea = 4*PI*r*r; solely dependent on the current situation
and is not influenced by the past
975
printf("Surface area of Sphere with radius as %d = %lf", r, surfacearea);
return 0;
}
Question 18 Redesign:
The modification of software components so that they carry out the same
Question: function as previously but in a new method and maybe by a different means
int number;
int i = 1;
printf("Enter number to generate Multiplication Table : \n");
scanf("%d", &number);
printf("Multiplication Table of %d : \n", number);
for(i; i <11; i++) {
Matplotlib:
printf("%d x %d = %d \n", number, i, i*number);
A Python open-source framework that
}
makes it simple to produce animated and
return 0;
interactive data visualization
}
976
Question 19 Mean Reciprocal Rank:
A statistic used to assess any process that generates a list of potential answers to a
Question: sample of questions, sorted by likelihood that the answers are correct
Solution:
#include <stdio.h>
int main() { Reliability Quality Attribute:
int principal; The extent to which a software application carries out specific
int rate; tasks under specific circumstances for a specific amount of time
int duration;
float SI;
printf("Enter Principal Amount : \n");
scanf("%d", &principal);
printf("Enter Rate of Interest : \n");
Resource Utilization Quality Attribute:
scanf("%d", &rate);
printf("Enter Duration : \n"); The extent to which a software application complies
scanf("%d", &duration); with requirements in terms of the types and amounts
SI = (principal*duration*rate)/100; of resources it uses to carry out its functions
printf("Simple Interest : %lf", SI);
return 0;
}
977
Question 20 Mini-batch:
A tiny collection of data that is randomly chosen from all possible examples
Question: and delivered to the machine learning model in a single iteration for training
Solution:
Round-trip engineering:
#include <stdio.h>
int main() { The idea of being able to update a
model in any way and also the code
float degree, fahrenheit; produced by that model
printf("Enter Temperature in Degrees : \n");
scanf("%f", °ree);
fahrenheit = (1.8*degree)+32;
printf("%f Degree in Fahrenheit : %f", degree, fahrenheit);
return 0;
}
978
Solution:
Question: Confidentiality
Solution:
Sensitivity point:
#include <stdio.h>
One component is a sensitivity point if it controls both
int main() {
runtime performance and reliability
float meter;
float feet;
printf("Enter Length in Meters : \n");
scanf("%f", &meter);
979
feet = (meter*3.2808);
printf("%f meter in feet = %f", meter, feet);
return 0;
}
Question:
float meter;
Testability Quality Attribute:
float feet;
printf("Enter Length in Feet : \n");
How effectively and efficiently test
scanf("%f", &feet);
requirements for a software application can be
meter = (feet/3.2808);
defined, and tests can be conducted to see if
printf("%f Feet in Meter = %f", feet, meter);
those requirements are fulfilled
return 0;
}
Time Behavior Quality Attribute: How well a software system satisfies requirements in terms of
response, processing and delivery performance while carrying out its functions
980
Question 24
Minimax: A decision rule for reducing the potential loss in a worst-case
(maximum loss) situation that is utilized in artificial intelligence, decision
Question: theory, game theory, statistics and philosophy
float cm;
float feet;
ML-as-a-service:
printf("Enter Length in Feet : \n");
scanf("%f", &feet); Various Machine Learning tools and
cm = 30.48 * feet; technologies that are offered in the cloud as a
printf("%f Feet in Meter = %f", feet, cm); service as part of cloud computing services
return 0;
}
981
Solution:
#include <stdio.h>
int main() { Broker:
Question 26
Question:
982
miles = (0.621371*km);
printf("%f Kilometer in Millimeter = %f", km, miles);
return 0;
}
Question 27
Question:
float yard;
float foot;
printf("Enter Length in Yard : \n"); Model capacity:
scanf("%f", &yard);
The degree of complexity of problems that a
foot = (3*yard);
ML model can learn. The complexity of the
printf("%f Yard in Foot = %f", yard, foot);
problem the ML model can learn is inversely
return 0;
}
correlated with model capacity
Elastic Beanstalk: AWS solution that enables users to manage and deploy web applications in the
AWS Cloud without having to worry about the infrastructure
983
Question 28 Lambda:
Solution:
AWS Route 53
#include <stdio.h>
AWS Cloud Domain Name System web
int main() {
service that helps business organizations
turn domain names into IP addresses
float inch;
float cm;
printf("Enter Length in inch : \n");
scanf("%f", &inch);
cm = (2.54*inch); In an algorithm for a neural network, a
printf("%f inch in cm = %f", inch, cm); neuron represents a node. One output is
return 0; produced by a neuron from many inputs.
}
984
Solution:
#include <stdio.h>
int main() {
Question:
Snowball:
Solution:
A data transport solution that moves a lots of data in
#include <stdio.h> and out of the AWS cloud
int main() {
985
return 0;
}
Amazon Aurora:
Solution:
A large-scale relational database solution created for the cloud that is fully
#include <stdio.h>
compatible with MySQL and PostgreSQL and combines the flexibility,
int main() {
availability and efficiency of high-end economical databases
printf("%lf GB = %lf MB", gb, mb); A stock indicator frequently employed in technical
return 0;
analysis that establishes a continuously updated
}
average price to assist smooth out price data
Amazon ElastiCache
AWS managed caching service that sets up, runs, and scales well-known in-memory
data stores that are compatible with open source
986
Question 32
Data Pipeline:
Solution:
987
#include <stdio.h>
int main() {
AWS CloudSearch:
float kg, lbs;
AWS managed service that sets up, manages
printf("Enter Weight in Kilogram : \n");
and scales a search solution for our web
scanf("%f", &kg);
application in a simple and affordable way
lbs = kg*2.20462;
printf("%f Kg = %f Pounds", kg, lbs);
return 0;
}
Question:
return 0;
988
Question 35 Amazon Cloudwatch:
#include <stdio.h> AWS solution that aids in the creation and management of the
int main() { encryption keys used to encrypt data
AWS CloudTrail:
Question 36
AWS solution that records usage of the API and AWS
accounts for risk assessment, accountability and surveillance
Question:
989
Solution:
AWS CloudFormation:
#include <stdio.h> AWS solution that aids in modeling and setting up
int main() {
our AWS resources so we may spend more time
concentrating on our AWS-running apps and less
int algebra, geometry, arithmetic;
time managing those resources
int sum;
float percentage;
printf("Enter Marks Scored in Algebra : \n");
scanf("%d", &algebra); Application virtualization:
printf("Enter Marks Scored in Geometry : \n");
The process of an operating system and an
scanf("%d", &geometry);
application communicating to each other
printf("Enter Marks Scored in Arithmetic : \n");
scanf("%d", &arithmetic); even when they are not directly connected
sum = algebra + geometry + arithmetic;
percentage = (sum*100)/300;
printf("Total marks scored = %d /300 \n", sum );
printf("Percentage Scored = %f", percentage );
return 0;
}
AWS Developer Tools: A set of services intended to aid users in creating, testing
Question 37 and deploying their own code
AWS Management Tools: A set of services that enable users to manage, monitor,
automate and deploy all cloud environment components programmatically
Question:
A problem where there are more than two classes for the target variable
#include <stdio.h>
990
int main() {
Block storage:
float price;
A technique of storing data where each
float discountpercentage;
storage volume functions as a separate hard
float discountamount;
disc that is set up by the storage admin
float discountedprice;
printf("Enter Price of Item : \n");
scanf("%f", &price);
printf("Enter Discount Percentage on Item : \n"); MXNet:
scanf("%f", &discountpercentage);
An open-source platform that
discountamount = (discountpercentage*price)/100;
discountedprice = (price-discountamount); facilitates the deployment and
Cloudless Computing:
Solution:
Releasing developers from restrictions that require
#include <stdio.h>
them to decide whether to deploy in a private or public
int main() {
cloud for any given workload and then stick with that
decision for the lifetime of the application
991
printf("Enter first number : \n");
scanf("%lf", &first);
printf("Enter second number : \n");
scanf("%lf", &second);
printf("Before Swapping => first number : %lf second number : %lf \n", first, second);
temp = first;
first = second;
second = temp;
printf("After Swapping => first number : %lf second number : %lf", first, second);
return 0;
}
Solution:
Hybrid Workplace: A scenario where employees have the
#include <stdio.h>
choice of working remotely or in an office as their workplace
int main() {
992
first = first + second;
second = first - second;
first = first - second;
printf("After Swapping => first number : %lf second number : %lf", first, second);
return 0;
}
Exascale computing:
Question 40
Computing systems capable of performing a billion billion
calculations per second (1018 calculations per second)
Question:
Hypervisor :
Solution:
Software that makes it possible for several virtual machines
#include <stdio.h> (VMs) to share resources from a single server
int main(){
993
Question 41
Packet-Switched Network:
Question:
A network that packetizes data transfers between computing devices
Intelligent edge:
Solution:
A location where data is created, examined, evaluated and dealt with
#include <stdio.h>
int main() {
Infrastructure Security:
int n, m, sum = 0;
printf("Enter a number: \n"); The process of defending key infrastructure against
scanf("%d", &n); physical and digital threats
m = n;
while (m != 0) {
In-memory computing:
sum = sum + m % 10;
m = m / 10; A technique of using RAM to store
} data instead of databases that are
printf("Sum of digits of %d = %d", n, sum); hosted on drives
return 0;
}
Intelligent Storage:
Question 42
A hybrid cloud environment data storage system that employs AI to
constantly adapt and evolve to improve data management and service
Question:
994
Solution: IT Asset Management:
int A, B, C;
printf("Enter the numbers A, B and C: \n"); IT procurement:
scanf("%d %d %d", &A, &B, &C); A set of procedures for acquiring and
if (A >= B && A >= C)
implementing information technology
printf("%d is the largest number.", A);
in alignment with business strategy
if (B >= A && B >= C)
printf("%d is the largest number.", B);
if (C >= A && C >= B)
printf("%d is the largest number.", C);
return 0;
}
Kubernetes:
Question 43
An open-source Cluster Management Software for managing, scaling
and automating the deployment of containerized applications
Question:
Object storage:
Solution:
An approach to data storage that effectively organizes data as
#include <stdio.h> objects with supplementary Meta information and unique IDs
int main() {
995
char ch;
printf("Enter a character : \n");
scanf("%c", &ch);
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') {
printf("%c is a Vowel!", ch);
}
else { Hybrid WAN: A wide area network
printf("%c is a Consonant!", ch); that distributes traffic among two or
}
more different types of connections
return 0;
}
Solution: Multi-Cloud:
#include <stdio.h> A cloud computing architecture wherein an enterprise organization divides its
int main() { resources over at least 2 clouds from various vendors, either public or private
int year;
printf("Enter a Number : \n");
scanf("%d", &year);
if ((year % 400 == 0) || ( ( year % 100 != 0) && (year % 4 == 0 ))) {
printf("%d is a leap year!", year);
}
996
else {
printf("%d is not a leap year!", year);
}
return 0;
}
Memory-Driven Computing:
Question 45
An architecture that is practically indefinitely adaptable and
expandable, capable of completing any computing work far more
Question: quickly and efficiently than traditional methods
int num, i;
long int fact; Zero Trust:
printf("Enter an integer number: \n");
An authentication and authorization strategy
scanf("%d", &num);
built on the principle that no user or piece of
fact=1;
software can be trusted by default
for(i=num; i>=1; i--)
fact=fact*i;
printf("Factorial of %d is : %ld", num, fact);
return 0;
}
997
Question 46 Remote Infrastructure Management:
Solution:
Tech Refresh:
case 2:
printf("The 2nd day of week is : Monday"); Supercomputing:
break;
A kind of high-performance computing that
effectively combines the processing capacity of
case 3:
numerous computing systems to handle
printf("The 3rd day of week is : Tuesday");
exceedingly complicated data-intensive challenges
break;
case 4:
printf("The 4th day of week is : Wednesday");
break;
998
case 5:
printf("The 5th day of week is : Thursday");
break;
case 7:
printf("The 7th day of week is : Saturday");
break;
Security Monitoring:
default:
The computerized process of identifying and
printf("Invalid input!! .....");
analyzing potential security threat indicators, then
}
return 0; classifying and responding to those threats
}
Hyperconverged Infrastructure:
Question 47
A software-based approach to fuse the data center's
networking, storage and computation systems
Question:
int number;
999
printf("Enter a number : \n");
scanf("%d", &number);
if(number > 0) {
printf("Entered number %d is a positive number", number);
}
else if(number < 0) {
printf("Entered number %d is a negative number", number);
}
else {
printf("Entered number %d is neither positive nor negative", number);
}
return 0;
}
Question:
Solution:
char ch;
printf("Enter a alphabet : \n");
FlowVisor:
scanf("%c", &ch);
A network virtualization hypervisor that enables several
if(ch>=65 && ch<=90) clients to share the same physical infrastructure
1000
printf("upper case"); Anti-Virus Gateway:
return 0;
}
Application firewall:
Solution:
A kind of firewall that checks, keeps an eye on and manages access to and
#include <stdio.h>
from applications and services on networks, the Internet and local systems
int main() {
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31},m;
printf("Enter the month: \n");
Data Lineage:
scanf("%d", &m);
A lifespan of data that takes into account
if(m>12 || m<1) { the origin of data, what happens to the
printf("Invalid input"); data and where data goes over time
}
1001
else if(m==2) {
printf("Number of days in month 2 is either 29 or 28"); Scaling:
Cisco onePK:
Solution:
A framework that allows developers to create an application that
#include <stdio.h>
is simple to incorporate into a Cisco infrastructure
#include <string.h>
int main() {
1002
Question 51
Enterprise Data Center Networking:
A business data center's networking that links users and servers together
Question:
A widely used technology that enables file extraction from network traffic and inspects it to
look for malware, Trojan horses, bugs or computer viruses
1003
Question 52 Data observability: Enterprise organization's ability to record,
evaluate and recommend a course of action regarding the status and
int a, b;
printf("Enter two numbers: \n");
Intent-Based Networking:
scanf("%d%d",&a,&b);
if(a>b) A technological idea that seeks to replace
printf("%d is a maximum number", a); manual methods for setting up networks and
else responding to network problems with a greater
printf("%d is a maximum number", b);
level of intellect and desired configuration
return 0;
}
Write a program to check whether the entered number is a prime number or not.
1004
Solution:
#include <stdio.h>
int main() {
Intrusion Detection System:
int num, i, x=0;
A passive computer security tool that keeps track
printf("Enter a number: \n");
of all incoming and outgoing network traffic
scanf("%d", &num);
return 0;
}
Question 54
Active attack: A perpetrator tries to change the message content
1005
Solution:
#include <stdio.h>
int main() {
Load Balancer:
Overlay network:
Solution:
A network that is supported by the infrastructure of another
#include<stdio.h>
network and is constructed on top of it
#include<conio.h>
int main() {
1006
return 0;
}
Quality of Service:
Question 56
The use of network-based technology to maintain the functioning of
crucial applications despite a limited available bandwidth
Question:
if (strcmp(a, b) == 0) {
printf("The strings are equal.");
} User and entity behavior analytics:
else {
A security tool that aids security teams in recognizing
printf("The strings are not equal.");
and managing unusual user activity that may be
}
indication of accounts that have been hacked
return 0;
}
1007
The total amount of energy entering a data center
Question 57 Power usage effectiveness =
The energy required to run its IT infrastructure
Question:
A measure used to evaluate a data center's energy efficiency
Python code:
Solution:
x = 1/5.77
#include <ctype.h>
print(x) # Output: 0.1733102253032929
#include <stdio.h>
int main() { print(format(x, '0.3f')) # Output: 0.173
Question 58 x = None
Question:
1008
Solution:
from datetime import datetime
#include <ctype.h>
print("Time now: {:%I:%M %p}".format(datetime.now()))
#include <stdio.h>
int main() { # Output: Time now: 03:28 AM
char ch;
ch = 'G';
printf("%c in lowercase is represented as %c", ch, tolower(ch));
return 0;
}
Question 59 1
Data center infrastructure efficiency =
Power usage effectiveness
Question:
1009
avg= (float)(num1+num2)/2;
printf("Average of %d and %d is: %.2f", num1, num2, avg);
return 0;
}
import itertools
Question 60
print(list(itertools.takewhile(lambda x: x < 13, itertools.count(11, .5))))
import time
Solution:
print(time.asctime())
#include <stdio.h>
# Output: Tue Jul 5 06:53:12 2022
int main() {
1010
Question 61
All pairs Testing:
The testing technique for identifying flaws that combines two test scenarios
Question:
Burndown chart:
Solution:
A graphical representation of the amount of work
Actual Outcome:
int a, b;
Actual output that a tester receives
a=2;
b = pow((a), 2); after running the test
Solution:
1011
#include<stdio.h>
int main() {
API Testing:
Question 63
Number of decision outcomes that were carried out
Decision Coverage = × 100
Total number of decision outcomes
Question:
#include<stdio.h>
Employed to test a logical statement
int main() {
1012
q = &y;
if(*p>*q) {
printf("x is greater than y"); Backward Compatibility Testing:
}
The method for testing if a software application created
if(*q>*p) {
printf("y is greater than x"); for an older version of a platform still functions on a later
} version of that platform
return 0;
}
Question 64 Bebugging:
The deliberate insertion of known bugs and flaws into the software
application in order to track how quickly they are found and fixed
Question:
Solution:
Basis Path Testing: A white box testing methodology
#include <stdio.h>
where test cases are designed in accordance with logical paths of
int main() {
execution that can be followed within the software program
int x, *p;
x = 1;
p = &x; Equally likely outcomes:
printf("The address of the variable x =%d \n", p);
An experiment's results are all
printf("The value of the variable x =%d", *p);
equally likely to occur
return 0;
}
1013
Question 65
Boundary Testing:
Write a program to print the first 10 numbers starting from one together with
Solution:
Big Bang Integration Testing:
#include<stdio.h>
A methodology where all software modules or components are
int main() {
merged at once, after which the entire system is tested
int i;
for(i=1; i<=10; i++)
printf("Number=%d its square=%d its cube=%d\n", i , i*i, i*i*i);
return 0;
}
Question 66
Portability Testing:
1014
Solution:
#include<stdio.h>
int main() {
Breadth Testing:
char M;
A set of tests that verifies a software
printf("Enter any character: \n");
application's full functionality but does not
scanf("%c", &M);
printf("ch=%c", M); carefully examine each feature
return 0;
}
1015
Question 68 Code Free Testing:
Question:
1016
Question 69 Context Driven Testing:
Question: how they will be used or are predicted to be used in the real world
printf("%c\n", a);
return 0;
}
Conformance Testing:
Question 70
A software testing methodology used to confirm that a software
application complies with IEEE, W3C or ETSI standards
Question:
Write a program to find the incremented and decremented values of two numbers.
#include<stdio.h>
A hardware or software module's partial release
1017
int main() {
int a, b, c, d, e, f;
a = 10; Conversion Testing:
b=12; A testing methodology used to ensure that one data format can be
c=a+1;
transformed into another, with the converted data format being used
d=b+1;
correctly and effectively by the software application being tested
e=a-1;
f=b-1;
printf("The incremented value of a =%d \n", c);
printf("The incremented value of b =%d \n", d);
Learning rate:
printf("The decremented value of a =%d \n", e);
printf("The decremented value of b =%d \n", f); A tuning parameter in an optimization method
return 0; that determines the rate at which model
} parameters are updated based on the gradient
Einstein [6] = I A technique for examining the software program's data flow
Einstein [7] = N
1018
Defect Logging and Tracking:
Solution:
A methodology of identifying flaws in an software application
under test through testing or capturing customer comments,
#include<stdio.h>
followed by the development of subsequent iterations of the
int main() {
application that address the flaws or the client's comments
int i;
char name [8] = {' E', ' I', ' N', ' S', ' T ', ' E', ' I', ' N'};
for(i=0; i<8; i++)
printf("\n Einstein [%d] = %c", i, name[i]);
return 0;
}
Question:
of a software application
int answer;
answer = square();
printf("Square of the given number: %d", answer);
return(0);
1019
}
int square() { Domain Testing:
int x;
A method for testing software that involves
printf("Enter any integer: \n");
picking a tiny portion of test cases from an
scanf("%d", &x);
almost unlimited collection of test cases
return x*x;
}
Durability Testing:
Question 73
A method of software testing that offers a precise
evaluation of how our software application might
Question: function in both typical and unexpected circumstances
Solution:
#include<stdio.h>
int main() { Endurance Testing:
Error Seeding:
1020
Question 74
End-to-End Testing:
Solution:
Fair coin: A coin with an equal chance of landing heads-up or tails-up
#include<stdio.h>
Fair game: A game in which every participant has an equal
int main() {
opportunity to succeed
Infinite sample space: A sample space with an essentially limitless
int i =1;
do {
number of outcomes
printf("%d\n", i++);
} while (i<=5);
return 0;
}
Entry Criteria:
Question 75
A set of circumstances under which a test activity can be completed, or in the
absence of any of these circumstances, the test activity cannot be completed
Question:
body [y] = y
1021
Exhaustive Testing:
Solution:
The method of thoroughly testing a software
#include <stdio.h>
application to ensure that it cannot be damaged or
int main() {
crashed by an unforeseen circumstance
char i;
char body [4] = {'b', 'o', 'd', 'y'}; Quality gate:
for(i=0; i<4; i++)
printf("\n body[%c] = %c", body[i] , body[i]); Software that constantly evaluates and
return 0; keeps track of the source code's quality
}
Expected Outcome:
Solution:
The ideal output that should be obtained after running a test case
#include <stdio.h>
#include <ctype.h> Inter Systems Testing:
int main() {
A methodology for evaluating the integration points and functionalities
between several systems that share same data source
int a =2;
if(isalpha(a)) {
printf("The character a is an alphabet");
}
1022
else {
printf("The character a is not an alphabet");
}
Symbolic execution:
return 0;
} A technique for examining program to ascertain what
inputs trigger the execution of each part of a program
Globalization Testing:
Question 77
A kind of software testing carried out to make sure the software
application can operate regardless of the location and
Write a program to calculate the discounted price and the total price after discount
Given:
double PV;
printf("Enter purchased value:");
Localization Testing:
scanf("%lf", &PV);
if(PV>1000) { A method for evaluating the performance,
printf("Discount=%lf \n", PV* 0.1); reliability and applicability of software
printf("Total=%lf \n", PV - PV* 0.1); application for certain areas and regions
}
else if(PV>5000) {
1023
printf("Discount =%lf \n", PV* 0.2);
printf("Total=%lf \n", PV - PV* 0.2); Negative Testing:
}
Testing carried out to make sure the
else {
software application being tested
printf("Discount=%lf \n", PV* 0.3);
DOES NOT malfunction when an
printf("Total=%lf \n", PV - PV* 0.3);
} unforeseen input is provided
return 0;
}
The method used by testers − which combines manual and automated tests
Question:
Write a program to print the first ten natural numbers using while loop statement.
Progressive Testing:
Solution:
Testing modules one after another
#include<stdio.h>
int main() {
int i = 1;
Positive Testing:
while(i<=10) {
printf("%d\n", i++); A kind of testing that involves using authentic datasets
} as input to test a software application
return 0;
}
1024
Prototype Testing:
Question 79
Testing carried out to look for issues before the
software application goes live
Question:
int age;
printf("Enter age: \n"); Requirements traceability:
scanf("%d", &age);
Keeping track of requirements during the entire software
if(age>=60) {
printf("senior citizen"); application development process
}
else {
One-tail test:
printf("not a senior citizen");
} A statistical test designed to demonstrate that the sample
return 0; mean would either be more than or less than the
} population mean, but not both
1025
Scenario Testing:
Solution:
A method of testing software applications that does not rely on
#include<stdio.h> test cases but rather on real-world scenarios
int main() {
Question: behaves when a series of various input conditions are sent through it
Structural Testing:
Solution:
A white box testing strategy where the tests are
#include <stdio.h>
designed by understanding the underlying workings
int main() { of the software application
int side1, side2, side3;
1026
if((side1 + side2 > side3)&&(side2 + side3 > side1) &&(side3 + side1 > side2)) {
printf("It is a Valid Triangle");
} else {
printf("It is an invalid Triangle");
}
Storage Testing:
return 0;
} A software testing method carried out to verify if the application
being tested saves the necessary information in the proper
directories and has adequate space to prevent unexpected
application terminations brought on by a lack of disc space
Question 82
Question:
Shift Left:
Solution: A methodology used early in the software delivery process to identify and prevent BUGS
#include<stdio.h>
int main() {
Unreachable Code: A section of the
source code that can never be executed
int angle1, angle2, angle3, sum;
printf("Enter Three Angles of a Triangle : \n");
because of improper control flow or exit points
1027
return 0;
}
Joint probability:
Question 83
A statistical measure that determines the probability of 2 events
happening simultaneously and at the same time
Question:
Write a program to print your name, date of birth and email address.
Verification Testing:
Solution:
The process of verifying that the software complies with all established
#include <stdio.h> software requirements including documents, code, designs and programs
int main() {
Write a program to convert specified days into years, weeks and days.
1028
Service Level Indicator:
Solution:
A measurement of the level of service that a service
#include <stdio.h>
provider offers to a consumer
int main() {
Loop Testing:
Question 85
A type of software testing that only examines if loop
constructs are accurate
Question:
Solution:
Coverage Item: An entity or characteristic that
1029
int pass, a;
while (a!=0) {
printf("Input the password: \n");
scanf("%d", &pass); Feedback loops:
Bitmap:
Question 86
An image file format that is suitable for storing and
producing computer graphics
Question:
Solution:
A variable without restrictions is said to be free
#include <stdio.h> variable. On the other hand, a bound variable is
int main() { a variable with restrictions
int x, i;
printf("Enter a number : \n");
1030
scanf("%d", &x);
printf("All the divisor of %d are: \n", x); CommonJS:
Context switch:
Question 87
A method that the central processing unit (CPU) of a computer uses to switch
from one task (or process) to another while making sure the tasks do not clash
Question:
int a, b;
printf("Enter a integer : \n"); Display advertising:
scanf("%d", &a);
The practice of promoting a service or product
printf("Integer value = %d \n", a);
using visuals such as pictures and videos on
a<<=2;
networks of publisher websites like Facebook
b=a;
and Google Display Network, etc.
printf("The left shifted data is = %d \n", b);
return 0;
1031
}
Question 88 Folksonomy:
int num;
printf("Enter a positive or negative number: \n");
scanf("%d", &num);
printf("Absolute Value of |%d| is %d", num, abs(num));
return 0;
}
import itertools
x = itertools.count(11, .5)
x = 'Einsteinian %s to %s Papers'
print(next(x)) # Output: 11
print(x % (1905, 1915))
print(next(x)) # Output: 11.5
# Output: Einsteinian 1905 to 1915 Papers
print(next(x)) # Output: 12.0
1032
Jamstack:
Question 89
Architecture created to increase the web's speed, security, and
scalability. It expands on many of the procedures and
Question: technologies that maximize efficiency for developers
Write a program to accept the height of a person in centimeter and categorize the
MAMP:
int main() { PHP, Perl, or Python (programming languages used for web development)
float height;
printf("Enter the height of the person (in cm) : \n");
scanf("%f", &height); Object-Oriented CSS:
1033
Offline-First:
Question 90
A model for programming where the software application must
function equally well offline as it does online
Question:
int choice, r, l, w, b, h;
float area;
printf("Enter 1 for area of circle\n");
Palpable content:
printf("Enter 2 for area of rectangle\n");
printf("Enter 3 for area of triangle\n"); When content is rendered and
printf("Enter your choice : "); substantive, it is palpable since it is
scanf("%d", &choice); neither empty nor concealed
switch(choice) {
case 1:
printf("Enter the radius of the circle : \n");
scanf("%d", &r);
area=3.14*r*r;
break;
case 2:
printf("Enter the length and width of the rectangle : \n");
scanf("%d%d", &l, &w);
area=l*w; TOML: A basic configuration file format
break; with clear semantics that is easy to read
1034
case 3:
printf("Enter the base and height of the triangle : \n");
scanf("%d%d", &b, &h);
area=0.5*b*h;
break;
Robots exclusion standard:
}
printf("The area is : %f", area); A protocol that websites employ to communicate
return 0; with web crawlers and other web robots
}
Sectioning content:
Solution:
Definitional content for headings and footers
#include<stdio.h>
#include<string.h>
int main() { Service Level Expectation:
char str[100];
The standard that the service provider must
1035
}
Three-Click Rule:
An official standard that claims that a user should always be able to get the
Question 92 information they're looking for in three clicks or fewer, but there is no
evidence to back this up, and it's now commonly believed to be a
misconception rather than a regulation that should be rigidly followed
Question:
Solution:
Transcompiler:
#include<stdio.h>
int main() { A specific kind of compiler that converts the
source code of one programming language
int a, b; into the source code of another
a=125;
b=35;
a=a>>1; TrustRank:
printf("After right-shifting by 1, a=%d\n", a);
An algorithm that uses link
b=b<<2;
analysis to distinguish between
printf("After left-shifting by 2, b=%d\n", b);
spam and valuable websites and
return(0);
aids in the fight against web spam
}
A security model where a client must establish trust with an unidentified server
1036
Question 93 Type coercion:
Typography:
The technique of organizing words and letters so that the reader can
Solution: easily read, understand, and find the copy visually appealing
#include<stdio.h>
/* Web bug:
int main() {
Uninitialized variable:
int a = 10, b = 20, c;
c = (a < b) ? a : b;
A declared variable that isn't given a clear, predetermined value
printf("%d", c); before use. When a variable is not initialized, its value is equal to
return(0); whatever garbage value is in the memory assigned to the variable
}
UNIX philosophy:
1037
Question 94
YAML Ain't Markup Language:
Write a program to accept a character from the keyboard and print "yes" if it is
1038
Solution: Discriminative models:
addition:
Kernel Trick: An easy method for classifying data that
printf("%d", sum);
cannot be linearly divided by a plane by projecting
return 0;
}
nonlinear data onto a higher dimension space
Server farm:
Question 96
A large group of servers, possibly thousands, working
together to improve functionality and accessibility
Question:
#include <stdio.h>
1039
int main() {
Data annotation:
int i = 10;
The labeling and classification of data for AI applications
for( ; ;) {
printf("%d\n", i);
} It is always preferable to use the median rather than the mean
return 0; when the data is skewed. The more skewed the data is, the less
} accurate is the mean and the more accurate is the median
A/A Testing:
Question 97
A technique that involves comparing two identical versions of the
same web application to see whether there is any difference
Question:
More than two variations of the same concept are being compared
#include <stdio.h>
#define A 15
int main() { Multivariate:
1040
Question 98 AdaGrad:
Question:
Question 99 Agent:
1041
Solution:
AlexNet:
#include <stdio.h>
Deep learning image recognition architecture
int main() {
long number, x;
printf("Enter a integer: \n"); You Only Look Once (YOLO):
scanf("%ld", &number);
x = number;
number = number << 2; A real-time object detection algorithm that
printf("%ld × 4 = %ld\n", x, number); recognizes objects using features obtained
return 0; from a deep convolutional neural network
}
Attention mechanism:
Question 100
Instead of using the complete input sequence, the ML model just considers portions
of it where the most significant information is concentrated when predicting an output
Question: word. In other words, it just takes into account a select few input words
int num;
printf("Enter a number : \n");
scanf("%d", &num);
1042
if((num != 0) && ((num &(num-1)) == 0)) { Attribute:
printf("%d is a power of 2", num);
The feature of an observation
}
else {
printf("%d is not a power of 2", num);
}
return 0;
}
Area under the curve (AUC)
Question:
Solution: Autocorrelation:
1043
}
else {
printf("The given Triangle is scalene.");
}
return 0; Automatic summarization:
}
The method of conveying the desired message by using a software
program to condense lengthy texts and produce summaries
Write a program to print ASCII values of all the letters of the English alphabet
from A to Z.
Automation bias:
Solution:
The tendency for people to dismiss contradicting information
#include <stdio.h>
supplied without automation, even if it is true, and to favor ideas
int main() {
from automated decision-making systems
int i;
for(i='A'; i<='Z'; i++) { Black box
printf("ASCII value of %c = %d\n", i, i);
}
return 0;
}
A system in which the input and output
are the only things that are known
1044
Question 103 Candidate generation:
Bootstrap aggregating:
Solution:
An approach to ensemble learning that boosts the
#include <stdio.h> efficiency and precision of machine learning algorithms
int main() {
Baseline model:
Question 104
A basic model that is trained first, and whose performance serves as
the standard for all future algorithm training and performance
Question:
1045
Solution:
Candidate sampling:
#include <stdio.h>
int main() { A method to reduce training time for
problems involving many labels
int i, num, sum=0;
printf("Enter a number: \n");
scanf("%d", &num);
Databricks → Unified data science platform
for(i=1; i<=num; i=i+2) {
sum = sum + i;
}
printf("Sum of all odd number between 1 to %d: %d", num, sum);
return 0;
}
Question 105
Centroid:
Solution:
Centroid-based algorithm:
#include <stdio.h>
An unsupervised machine learning approach to clustering
int main() {
where data is arranged around a cluster center
1046
switch(num1 > num2) {
case 0: printf("%d is Maximum number", num2);
break;
CIFAR-10:
Question 106
A dataset that is well-understood and frequently used in the field of
machine learning to evaluate computer vision algorithms
Question:
switch(operator) {
case '+':
1047
printf("%.1lf + %.1lf = %.1lf", x, y, x + y);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf", x, y, x - y);
break;
Convergence:
case '*':
A machine learning model
printf("%.1lf * %.1lf = %.1lf", x, y, x * y);
reaches convergence when a
break;
trained model no longer sees
its error decreased or only
case '/':
slightly if we add additional
printf("%.1lf / %.1lf = %.1lf", x, y, x / y);
break;
data for training
default:
printf("Error! Please enter correct operator");
}
return 0;
}
Continuous learning:
Question 106
The potential of a ML model to learn in a production environment while
being trained with a stream of real-time data
Question:
Convenience sampling:
Solution:
A kind of sampling where the first main data source that is accessible will
#include<stdio.h> be used for the study without any further criteria
1048
#include<math.h>
int main() {
Cosine similarity:
int number; A parameter used in text mining to
double result;
evaluate how similar documents are
printf("Enter any integer number: \n");
scanf("%d", &number);
result = sqrt(number);
printf("Square root of %d is %.2lf", number, result);
return 0;
}
The phase of a data science project where unclean and unusable raw data is cleaned up
Question: and processed to produce clean and useable data for data investigation or modeling
Solution: DataFrame:
1049
return 0;
}
Question: that creates clusters by combining points that are close to one another
Solution: Decile:
#include <stdio.h> A descriptive statistic with nine values dividing the data into ten
#include<ctype.h> equally sized pieces. Each part represents one-tenth of the data
int main() {
1050
DeepDream:
Question 109
A Google-developed computer vision approach that generates
images or transforms existing images into a dreamlike vision using a
Question: deep convolutional neural network
Dropout:
1051
Question 110 The smallest intercluster distance
Dunn index =
The largest intracluster distance
A high Dunn index indicates better clustering since observations inside each
Question:
cluster are closer together while the clusters themselves are farther apart
or not.
Embedding space:
Solution:
#include<stdio.h>
#include<ctype.h>
int main() { Feature cross:
i = 1
Output:
while i < 4:
Alan
print('Alan')
Alan
i = i + 1
Alan
1052
Question 111 Apache flume:
Solution:
Federated learning:
#include<stdio.h>
A method of machine learning that trains an
#include<ctype.h>
algorithm on a number of distributed edge
int main() {
devices or servers that keep local data
samples without exchanging them
char a;
printf( "Enter a character : \n");
scanf( "%c", &a );
if(isgraph(a)) {
printf( "%c is a character with graphical representation.", a );
}
else {
printf( "%c is NOT a character with graphical representation.", a );
}
return 0;
}
x = ' ' * 6
print(5 + int('5'))
print('%s 1905 Papers' % x) # Output: 10
# Output: 10.6
1905 Papers
1053
Question 112 Generalization curve:
Question:
validation over several iterations
Forget gate:
int i; Generator
for(i = 1; i <= 127; i++)
if(isprint(i)!= 0)
printf("%c ", i);
A part of a generative adversarial neural network that
return 0;
creates bogus data out of randomness in a latent space
}
1054
Solution:
#include<stdio.h>
#include<ctype.h> Ggplot2:
int main() {
A well-liked R programming library for
data visualization
char a;
printf("Enter a character : \n");
scanf( "%c", &a );
if(isxdigit(a)) {
printf("%c is a hexadecimal digit character.", a );
}
else {
printf("%c is NOT a hexadecimal digit character.", a );
}
return 0;
Highway network:
}
A neural network that assists in very deep neural network training
1055
int main() {
int i;
printf("The ASCII value of all control characters are: \n");
for (i=0; i<=127; ++i) {
if (iscntrl(i)!=0) Implicit bias:
printf("\n %d ", i);
Making an incorrect or partially true assumption
}
before beginning a machine learning project
return 0;
}
Inception:
Solution:
The deep learning architecture for image classification,
#include <stdio.h> particularly CNNs (convolutional neural networks)
#include <ctype.h>
int main() {
Instance-based learning:
char ch = 'a';
A sort of memory-based learning
if (isprint(ch)) {
machine learning method that compares
printf("%c is printable character \n", ch);
} else {
newly arriving data with previously
printf("%c is not printable character", ch); stored data rather than generalizing
} based on training data
1056
if (iscntrl(ch)) {
printf("%c is control character\n", ch);
} else {
printf("%c is not control character", ch);
}
return (0); Kernel support vector machine:
}
A classification technique that transforms the input
data vectors into a higher-dimensional space to
address the issue as though it were non-linear
or not.
Iteration:
#include <stdio.h>
#include <ctype.h> Kullback–Leibler divergence:
int main() {
A statistic to assess how two probability
printf("Enter a character : \n"); used to evaluate how far the continuous and
scanf("%c", &c); discrete probability distributions diverge
if (isspace(c) == 0) {
printf("Not a white-space character.");
}
else {
1057
printf("White-space character.");
}
return 0;
}
print(list(zip(range(4), 'ALAN')))
# Output: [(0, 'A', 1), (1, 'L', 2), (2, 'A', 3), (3, 'N', 4)]
import itertools
print(list(itertools.accumulate([1, 2, 3, 4, 5])))
import itertools
print(list(itertools.repeat(7, 3)))
# Output: True (1 + 0 == 1)
print(list(itertools.repeat(6, 2)))
print(True * True == 1)
# Output: [6, 6]
# Output: True (1 * 1 == 1)
x = itertools.repeat(6)
# Output: 6 6 6
1058
i = 3
Output:
for a in range(1, 5):
Albert 1
print('Albert %s' % a)
Albert 2
if a == i:
Albert 3
print('Einstein')
Einstein
break
i = 3
Output:
for a in range(1, 5):
Albert 1
print('Albert %s' % a)
Albert 2
if a == i:
Albert 3
print('Einstein')
Einstein
pass
Albert 4
x= ('Albert', 1905)
C# program:
y = x + ('Papers',)
print(y)
public class HelloWorld {
# Output:('Albert', 1905, 'Papers')
System.Console.WriteLine("Albert Einstein");
1059
for _ in range(4):
x = ['5.36', '4.39', '3.55']
print('Albert Einstein')
print([float(i) for i in x])
Albert Einstein
import dis # dis() function generates disassembled representation of the Python code
# Output:
2 RETURN_VALUE
for i in range(3):
# Output:
print(i, "\t", 3**i)
0 1
1 3
2 9
1060
x = {1905: 'Papers'} print ('\\')
x[1915] = 'Papers'
print(x) # Output: \
# Output:
{1905: 'Papers', 1915: 'Papers'}
print ('A 5\'6" tall object')
x = str("1905 Papers")
# Output: A 5'6" tall object
print(x)
# Output: 1905 Papers
i = 4
x = "Alb"
print(x + "ert" == "Albert") while i> 0:
# Output: True
print (i)
Output:
x=2 i= i-1
4
print(x * 0 == 0)
# Output: True 3
2
print(not (not x) == x)
1
# Output: True
# Output:
Thxs xs a strxng
Thxs xs a string
1061
x = ['Apple', 'Orange', ['Banana', 'Grapes'], 'Figs', ['Guava']]
print(x, False)
print(x, True)
# Output:
x=11
y=12
z=13
print("x value is %i" %x)
print("y value is %d and z value is %d" %(y, z))
# Output:
x value is 11
x="alan"
print(x.count('a')) # Output: 2
print(x.count('al')) # Output: 1
1062
x = int(input("Please enter a number:"))
x=[5,10,15,20]
Output:
for i in x: 50/5 = 10.0
x=[11,12,13,14,15]
for i in x: Output:
if i>=20: 11
12
print("Failed to process")
13
break 14
15
print(i)
Successfully processed
else:
print("Successfully processed")
1063
print("{:06d}".format(5496))
Output:
print("{:8.3f}".format(549.6555))
005496
print("{:08.3f}".format(549.6555))
549.655
print("{:08.3f}".format(549.65))
0549.655
print("{:08.3f}".format(54961988.6555))
0549.650
54961988.656
a='Albert'
b ='Einstein'
c=1905 Part of speech tagging:
Information scent:
The effectiveness of appropriate messaging along the customer journey, as well as the presence of visual
and textual signals that notify website visitors of the type of content that is available there
1064
Nash equilibrium:
a
A game theory decision-making principle that claims a player can attain the
desired result by adhering to their initial approach b
Negative class: d
There are two classes in binary classification, one of which is classified as positive and e
the other as negative. As an illustration, consider the contradiction spam or not spam, f
where spam is the positive class and not spam is the negative class
g
h
Neural Turing Machine: i
l
No free lunch theorem:
m
There isn't a single model that works best in all circumstances. It is typical n
in machine learning to test several models in order to find the one that
o
works the best for a given problem because the assumptions of a good
p
model for one issue could not hold true for another
q
Java Program: r
t
public static void main(String[] args) {
u
for(int i = 0; i <= 25; i++) {
v
char x = (char) ('a' + i); w
Output
System.out.println(x); x
y
}
z
}
1065
Nominal variable:
A categorical variable without a clear hierarchy and having two or more categories. For example, a
variable termed color may include the names of many colours, such as orange, green, black, and
white. This is a nominal variable since it includes categories without any established hierarchy
Null accuracy:
A minimum level of accuracy determined by just projecting the most common class
NVIDIA:
A graphics processing unit designed for working with graphics and image processing
Python code:
import math
Q-function:
print(math.sin(3) + math.cos(3))
The probability that a normally distributed
# Output: -0.8488724885405782 (Gaussian) random variable will have a value
higher than the standard deviations
print(array.array('i', list(range(5))))
1066
import numpy as np
print(x)
# Output: [5 0 3 3 7 9]
print(y)
# Output:
[[5 0 3 3]
[7 9 3 5] [[[5 0 3 3 7]
[2 4 7 6]] [9 3 5 2 4]
[7 6 8 8 1]
[6 7 7 8 1]]
z = np.random.randint(10, size=(3, 4, 5)) # Three-dimensional array
print(z)
[[5 9 8 9 4]
# Output
[3 0 3 5 0]
[2 3 8 1 3]
[3 3 7 0 1]]
[[9 9 0 4 7]
[3 2 7 2 0]
[0 4 5 5 6]
[8 4 1 4 9]]]
1067
Objective:
The goal that a machine learning algorithm seeks to maximize. Every machine
learning algorithm must have a defined objective for each issue
Apache Oozie:
import numpy as np
x = np.arange(3)
print(i)
print(-(0.5*x + 1) ** 2)
# Output: [0 1 2]
# Output: [-1. -2.25 -4. ]
print(i + 3)
# Output: [3 4 5]
print(i - 3)
# Output: [0 0 1]
1068
Pig:
An advanced programming language used with Apache Hadoop. Without learning Java, data engineers
may perform sophisticated data transformations with Pig
Post processing:
The methodology used to refine and assess the information obtained by the data mining technique
Pre-processing:
A process of data transformation and cleaning in which unprocessed data is adjusted and
made ready for machine learning algorithms. Pre-processing is an important stage in
machine learning since it lowers interference and improves model performance
import numpy as np
print(np.all(i == 15))
# Output: False
All the presumptions made regarding the
data, including distribution assumptions,
# Are there any values equal to 15? correlation assumptions, assumptions on the
data gathering process, and so forth
print(np.any(i == 15))
# Output: True
1069
Random initialization:
The procedure of initializing the parameters of a machine learning model using random numbers
import pandas as pd
import numpy as np
x = pd.DataFrame(np.random.rand(4, 2),
print(x)
# Output:
Reward:
A B
A crucial idea in reinforcement learning because it
w 1 0.921158 0.083112 instructs the agent on how successfully it is carrying
out a task and enhances the model as a whole
x 2 0.277719 0.009357
y 3 0.842342 0.647174
z 4 0.841386 0.264730
Relationship extraction
A methodology for extracting the semantic relationship between two or more entities in
natural language processing. For example, the relationship between the entities Bangalore and
India is conveyed by the word "is in" in the sentence "Bangalore is in India."
1070
Cobra Effect:
Summary statistics:
API Response
Descriptive statistics that provide a • C → Create → POST
concise summary of a dataset and can be • R → Read → GET
used to extract important information • U → Update → PUT
1071
Data Dredging: Boolean
A logical data type that can have only the values true or false
Data mining techniques are misused in the
practise of data dredging, also known as
data snooping or data fishing, in order to
present false scientific "research" Latency
Survivorship Bias: The time delay between a user's action and a web application's
response to that action
Focusing only on things that
were chosen and ignoring others High latency → poor user experience
may result from this to pass from one point on a network to another.
Gambler's Fallacy
Cyber security:
1072
Code review
McNamara fallacy:
A process where someone other than the author of a piece of code
Making a choice based only on examines that code to find and remove the weaknesses or flaws in the
quantitative observations, while code that impact software performance and security
ignoring all other observations
1073
3 principles that form the cornerstone of Publication Bias:
any organization's security infrastructure:
The likelihood of a research discovery being published depends
on how entertaining it is, which distorts our perception of reality
• Confidentiality
• Integrity
• Availability Anchoring Bias:
Stop words:
Remix
A stop word is a frequently used term that a search engine has
The process of creating a new version been configured to ignore − both while indexing entries for
of a program by recombining and searching and when retrieving them as the result of a search
modifying parts of existing programs query. Examples of stop words include "the," "a," "an," and "in."
1074
Data Backup Acquiescence bias:
Administrative databases:
A small software program that is Huge databases of information gathered in health care for a variety
intended not to be run on its own − of objectives. Hospitals, healthcare institutions, and health
but rather to be embedded inside insurance firms are the main institutions that keep such databases
another larger application program
Admissibility:
Aliasing:
Business continuity plan
A scenario when several symbolic names
A written document that outlines how a
within the program can be used to access the
business will operate during an emergency
same data location in memory
• Risk assessment (Analysis)
• Design strategies and tactics for recovery
Audit trail
• Implementation
• Testing and acceptance
• Maintenance
A software program that logs database updates
1075
Content management system
Ascertainment bias:
A software application that allows users Bias is when some members of the target group are less likely to
to create, manage and modify content on a be included in the results than others when data is collected (or
website − without having to code it from surveyed, filtered, or documented) for a study or analysis
Behrens-Fisher problem:
A type of memory that retains A statistical concept that claims that when a large
sample size has a finite variance, the samples will have
information even after power
a normal distribution and their means will be roughly
is turned off equal to the population's mean
1076
System call:
Library call
Library
Library
Pre-compiled object code which is used in source code file to provide functionality for a pre-defined
function or user-defined functions
Called during the compilation of the program Called during run-time and not during the
compilation of the program
1077
Bagplot: Box-and-whisker plot:
A method for finding outliers in A visual way for highlighting the key characteristics
bivariate data of a group of observations
Cluster sampling:
Chernoff faces:
A method of data visualization where multivariate data is presented in the form of a human face
Coarse data:
A word occasionally used when information is neither fully missing nor entirely present
Ceiling effect:
IP address:
1078
#include<iostream>
a = addition(6,2);
return 0;
IDE
Eclipse and
(Integrated Development Environment)
NetBeans
A software tool to help you write software
Wi-Fi
A wireless method of sending high speed information over short distances using radio waves
Bandwidth:
The maximum amount of information transmitted over an internet connection in a given amount of time
1079
Compute Intensive – A single application program requiring a large amount of computation.
Interpreter
Packet: Ransomware:
A unit of information into which data is Malware designed to deny a user access to
broken up for transmission in a network files on their computer
Functional abstraction:
The details of how a function is implemented are hidden from the consumer of the function
Windows:
Architectural design
The process of defining a collection of hardware and software components and their interfaces to
establish the framework for the development of a computer system
1080
Bootstrap:
A free and open source front-end framework for designing websites and web applications
Debugger:
Time-sharing:
Multitasking:
Code → Computer instructions
The concurrent execution of multiple tasks or
Coding → programming
processes over a certain period of time
Coder → programmer
Allows multiple tasks or processes to
use a computer system at the same time
Scalability
Message
1081
HTML
Tim Berners-Lee
Robert Cailliau
The majority of Web Pages are written in HTML. Making web pages and online applications functional
requires the use of HTML. Beginning in 1989, Tim Berners-Lee, Robert Cailliau, and others
developed HTML for the first time. Hyper Text Markup Language is what it stands for. Only
HTML can be used to construct static web pages. We will concentrate on CSS, the code used to create
visually pleasing web pages, in a subsequent chapter. We'll concentrate on teaching you how to construct
right now rather than how to design.
HTML Documents
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
Example
<!DOCTYPE html>
1082
881
<html> <!-- The root element of an HTML Document -->
<head> <!-- HTML tag that hold meta information about the HTML Document -->
<title> Page Title </title>
Specifies a title for the HTML Document that will
</head>
appear in the title bar or tab of the web browser
<body> <!-- Defines the document's body that hold the content of HTML -->
</body>
</html>
HTML Headings
Example
This is heading 1
This is heading 2
<!DOCTYPE html>
<html> This is heading 3
<body> This is heading 4
This is heading 5
<h1>This is heading 1</h1>
This is heading 6
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
Used to display heading content
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
<h1 style="font-size: 40px;"> Heading no 1 </h1>
</html>
1083
881
Example
</body>
A paragraph always begins on a new line. Each paragraph
</html>
begins with the <p> tag and ends with the </p> tag
HTML Links
Example
<!DOCTYPE html>
<html>
This example demonstrates how to create a link to google.com
<body>
HTML Images
1084
883
Example
<!DOCTYPE html>
<html>
The HTML <img> tag is used to display image on the web page
<body>
</body>
src - Specifies the path to the image
</html>
alt - Describe the image in words
HTML Buttons
Example
<!DOCTYPE html>
<html>
<body>
<button> Click me </button> <!-- The <button> tag defines a clickable button -->
</body>
</html>
HTML Lists
There are 3 different types of HTML lists:
Example
1085
883
<!DOCTYPE html>
<html>
<body>
<ul>
</ul>
<ol>
</ol>
<dl>
</dl>
</body>
</html>
1086
885
HTML Tag Description # Output:
Apple
<ul> Defines an unordered list
Orange
Mango
<ol> Defines an ordered list
1. Apple
<li> Defines a list item 2. Orange
3. Mango
Example
<!DOCTYPE html>
<html>
<body>
</body>
# Output:
</html>
This is a
paragraph with a line break.
1087
885
HTML Attributes
HTML links are defined with the <a> tag. The link address is specified in the href attribute.
Example
<!DOCTYPE html> The URL of the page to which the link leads is
<html> specified by the "href" property
<body>
</body>
</html>
Example
Absolute URL
<!DOCTYPE html>
A link to an external image hosted on
<html>
another website
<body>
<img src="https://www.git.com/images/Alan-Turing.jpg">
<img src="Alan-Turing.jpg">
Relative URL
</body>
A link to an image that is hosted
</html>
within the website
1088
886
The width and height Attributes
HTML images also have width and height attributes, which specifies the width and height of the image
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
If an image cannot be displayed for some reason, the "alt" attribute for the
<img> tag provides an alternative text for the image. This can be the result
of a poor network connection or an issue with the src attribute
<html>
<body>
</body>
</html>
1089
The style Attribute
The style attribute is used to add styles to an element, like color, font, size etc.
Example
# Output:
<!DOCTYPE html>
Alan Mathison Turing.
<html>
<body>
</body>
Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a
<!DOCTYPE html>
When the mouse moves over the <p> element
<html> then it displays the text "Albert Einstein"
<body>
</body>
<!DOCTYPE html>
</html> <html lang="en-IN">
<body>
... Specifies the "English" as the
</body> language and "India" as the country
</html>
1090
888
HTML Horizontal Rules
The <hr> tag defines a thematic break in an HTML page, and is most often displayed as a horizontal rule.
The <hr> element is used to separate content (or define a change) in an HTML page.
Example
<!DOCTYPE html>
<html>
<body>
The <hr> tag is an empty tag and
<p> Albert </p>
it does not require an end tag
<hr>
</body>
</html>
# Output:
Albert
Einstein
<!DOCTYPE html>
# Output:
<html>
<body> Albert
<p> Albert </p>
<hr> Einstein
<h1> Einstein </h1>
<hr size="30">
</body>
</html>
Specify the height of the horizontal rule
"30 pixels"
1091
889
The HTML <pre> Element
Example
<!DOCTYPE html>
Line Breaks in HTML without the <pre> Tag
<html>
<body>
</html>
# Output:
Albert Einstein was a German-born theoretical physicist who developed the theory of relativity.
1092
889
HTML Styles
Background Color
The CSS background-color property defines the background color for an HTML element.
Example
This example sets the background color
<!DOCTYPE html> for a web page to "orange"
<html>
</body>
</html>
# Output:
HTML
HyperText Markup Language.
Text Color
The CSS color property defines the text color for an HTML element.
1093
889
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html> # Output:
HTML
The CSS font-family property defines the font to be used for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html> # Output:
HTML
HyperText Markup Language.
Text Size
The CSS font-size property defines the text size for an HTML element.
1094
891
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html> # Output:
HTML
HyperText Markup Language.
Text Alignment
The CSS text-align property defines the horizontal text alignment for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
<p style="text-align:left;">HTML</p>
<p style="text-align:center;">HTML</p>
<p style="text-align:right;">HTML</p>
</body>
</html>
1095
892
# Output:
HTML
HTML
HTML
<p> <strong> Albert </strong> </p> <! -- Defines important text --->
<p> <i> Albert </i> </p> <! -- Defines italic text --->
<p> <em> Albert </em> </p> <! -- Defines Emphasized text --->
<p> <mark> Albert </mark> </p> <! -- Defines Marked or highlighted text --->
<p> <del> Albert </del> </p> <! -- Defines Deleted text --->
</body>
</html> # Output:
Albert
Albert
Albert
Albert
Albert
1096
892
<!DOCTYPE html>
<html>
<body>
</body>
</html> # Output:
<!DOCTYPE html>
<html>
<body>
<p> Alan <ins> Mathison </ins> Turing </p> <! -- Defines inserted text --->
</body>
# Output:
</html>
E = mc 2
In most cases, web browsers will
highlight inserted text O2
1097
892
HTML Quotation and Citation Elements
<!DOCTYPE html>
The HTML <blockquote> tag defines a long quotation
<html>
<body>
<!--blockquote tag starts here -->
<blockquote cite= "https://en.wikipedia.org/wiki/Albert_Einstein">
# Output:
Albert Einstein was a German-born theoretical physicist, widely acknowledged to
be one of the greatest and most influential physicists of all time. Einstein is best
known for developing the theory of relativity, but he also made important
contributions to the development of the theory of quantum mechanics.
The element content is the text that appears between the start and end tags.
HTML tags are case-insensitive; <p> and <P> have the same meanings.
1098
892
<!DOCTYPE html>
<html> The HTML <q> tag defines a short quotation
<body>
</body>
</html>
# Output:
Albert Einstein was a “German-born theoretical physicist.”
<!DOCTYPE html>
<html> The HTML <abbr> tag defines an abbreviation
<body>
</html>
which is used to display the description for the
abbreviation when you hover your cursor over the element
# Output:
License Reassignment:
The right for one User to run the Software on one Computer being
1099
892
<!DOCTYPE html>
<html> The HTML <address> tag defines the contact
<body> information for the author of a HTML document
<address>
Written by Albert.<br> # Output:
Visit us at:<br>
Science.com<br>
Written by Albert.
Box 564, London<br>
Visit us at:
UK
Science.com
</address>
Box 564, London
UK
</body>
</html>
<!DOCTYPE html>
The HTML <cite> tag defines the title of a work (e.g.
<html>
movie, book, literature, sculpture, painting or drawing)
<body>
# Output:
Cosmos is a popular science book.
</body> # Output:
</html>
.koob ecneics ralupop a si somsoC
1100
892
HTML Comments
HTML tags typically come in
Comment tags are used to insert comments in the HTML source code. pairs like <p> and </p>. The
first tag in a pair is the
Because each line of HTML code may be individually commented out to check
<p> Albert <!-- Einstein --> was a German-born theoretical physicist. </p>
# Output:
Albert was a German-born theoretical physicist.
1101
892
<!DOCTYPE html>
<html>
<body>
</body>
# Output:
</html>
I have 2 red shirts.
<!DOCTYPE html> In this example, we used a span tag to modify the "red"
<p> I have 2 <span style="color: red; font-weight: bold"> red </span> shirts. </p>
<p> I have 2 <span style="color: red; font-family: 'Courier New'"> red </span> shirts.
</p>
<p> I have 2 <span style="color: red; font-size: 30px"> red </span> shirts. </p>
<p> I have 2 <span style="color: red; font-style: italic"> red </span> shirts. </p>
</body>
# Output:
</html>
1102
892
HTML Colors
HTML colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.
Background Color
# Output:
Example
HTML
<body>
</body>
</html>
Text Color
# Output:
Example
Albert Einstein
<body>
</body>
</html>
1103
899
Border Color
# Output:
Example
Albert
<html> John
<body>
</body>
</html>
Color Values
In HTML, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and
HSLA values:
Example
?
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color: rgba(255, 99, 71, 0.5);"> rgba(255, 99, 71, 0.5) </h1>
<h1 style="background-color: hsla(9, 100%, 64%, 0.5);"> hsla(9, 100%, 64%, 0.5) </h1>
</body>
</html>
1104
899
Color HTML Code
JavaScript Program:
<script>
Aqua #00FFFF
document.write("Hello World!");
Aquamarine #7FFFD4
</script>
Azure #F0FFFF </strong>
Beige #F5F5DC
Output:
Bisque #FFE4C4
Hello World!
Black #000000
Boldfaced by the web browser
Blanched Almond #FFEBCD
Blue #0000FF
Dynamic HTML
Blue Violet #8A2BE2
(REAL Interactivity)
Brown #A52A2A
Coral #FF7F50
+
1105
Corn silk #FFF8DC
Synchronous
Crimson #DC143C
Cyan #00FFFF
</script>
Dark Olive Green #556B2F
The string "2" is
Dark orange #FF8C00 converted to the
number 2.
Dark Orchid #9932CC
1106
Beige #F5F5DC
<script>
Dark Slate Grey #2F4F4F /* Display a text "Hi" once after 4 second
Gainsboro #DCDCDC
</script>
Ghost White #F8F8FF
4 second
Gold #FFD700 delay
Hi
Goldenrod #DAA520
Gray #808080
Grey #808080
1107
Green #008000
JavaScript + Cookie
Indigo #4B0082
<script type="text/javascript" src="gtag.js"></script>
Ivory #FFFFF0
The name of the file
Khaki #F0E68C
containing the script code,
usually ending with .js.
Lavender #E6E6FA
Lavender Blush #FFF0F5 The use of external script by placing the name
of the script file in the src (source)
Lawn Green #7CFC00 attribute of a <script> tag
console.log(Math.round(Math.PI));
Light Gray #D3D3D3
// Output: 3
Light Grey #D3D3D3
console.log(Math.ceil(Math.PI));
</script>
1108
Light Pink #FFB6C1
<script>
console.log(Math.min(4, 6) * 50);
White #FFFFFF
// Output: 200
Wheat #F5DEB3
Violet #EE82EE
console.log(Math.max(4, 6) * 50);
Light Slate Gray #778899
// Output: 300
Light Slate Grey #778899
</script>
Light Steel Blue #B0C4DE
</script>
1109
Turquoise #40E0D0
<script>
console.log("Albert");
Thistle #D8BFD8
if (11 < 22) {
Teal #008080
console.log("Einstein");
Tan #D2B48C }
</script>
Steel Blue #4682B4
Output:
Medium Blue #0000CD
Albert
Medium Orchid #BA55D3
Einstein
Spring Green #00FF7F
Snow #FFFAFA
<script>
Medium Purple #9370D8 console.log(5 * null);
console.log(false == 0);
Medium Slate Blue #7B68EE
// Output: true
Medium Spring Green #00FA9A
console.log(true == 1);
console.log(null == undefined);
Slate Grey #708090
// Output: true
Silver #C0C0C0
</script>
Sienna #A0522D
1110
Medium Turquoise #48D1CC
<script>
// Output: 2+2=4
Peru #CD853F
Plum #DDA0DD
console.log("A", "B", 5);
Navajo White #FFDEAD
// Output: A B 5
Navy #000080
</script>
Old Lace #FDF5E6
Orange #FFA500
function myfunc(name) {
Orchid #DA70D6 }
</script>
Pale Golden Rod #EEE8AA
Hi Albert
# Output:
How are you?
1111
Slate Blue #6A5ACD
<script>
console.log(i);
Papaya Whip #FFEFD5
break;
Peach Puff #FFDAB9
}
// Output: 22
Purple #800080
</script>
Red #FF0000
<script>
Rosy Brown #BC8F8F function repeat(n, action) {
action("Albert Einstein");
Saddle Brown #8B4513
}
}
Output: repeat(3, console.log);
1112
<script>
/*
*/
x.value = 100;
console.log(x.value); // Output: 15
</script>
HTML CSS
Inline CSS
This example sets the text color of the <h1> element to blue.
1113
<!DOCTYPE html>
<html> # Output:
<body>
HTML
<h1 style="color: blue;"> HTML </h1>
</body>
</html>
Internal CSS
• An internal CSS is defined in the <head> section of an HTML page, within a <style> element.
Example
<!DOCTYPE html>
<html>
<head>
<style>
# Output:
h1 {color: blue;}
HTML
p {color: red;}
</style> HyperText Markup Language.
</head>
<body>
</body>
</html>
1114
External CSS
• An external style sheet is used to define the style for many HTML pages.
• With an external style sheet, we can change the look of an entire web site, by changing one file!
• To use an external style sheet, add a link to it in the <head> section of the HTML page.
body {
Example background-color: orange;
}
h1 {
color: blue;
}
<!DOCTYPE html> p {
color: green;
}
<html>
<head>
</head>
<body> # Output:
</body>
</html>
CSS Fonts
Example
1115
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
# Output:
color: green;
font-family: verdana;
font-size: 200%; HTML
}
p { HyperText Markup Language.
color: blue;
font-family: courier;
font-size: 130%;
}
</style>
</head>
<body>
</body>
</html>
CSS Border
Example
1116
909
<!DOCTYPE html>
<html>
<head>
<style> # Output:
p {
border: 3px solid green;
HTML
} HyperText Markup Language.
</style>
</head>
<body>
<h1> HTML </h1>
<p> HyperText Markup Language. </p>
</body>
</html>
CSS Padding
• The CSS padding property defines a padding (space) between the text and the border.
1117
909
CSS Margin
• The CSS margin property defines a margin (space) outside the border.
Example
<!DOCTYPE html>
<html>
<head>
<style>
p {
border: 4px solid green;
margin: 50px;
}
</style>
</head>
<body>
</body> # Output:
</html>
HTML
1118
911
The id Attribute
• To define a specific style for one special element, add an id attribute to the element.
Example
<!DOCTYPE html>
<html>
<head>
# Output:
<style>
#p01 {
Albert Einstein.
color: blue;
Elsa Einstein.
}
</style>
</head>
<body>
</body>
</html>
• To define a style for special types of elements, add a class attribute to the element:
Example
<!DOCTYPE html>
1119
911
<html>
<head>
<style>
.p01 { # Output:
color: blue;
Albert Einstein.
}
</head>
<body>
</body>
</html>
Example
<!DOCTYPE html>
<html>
1120
<body>
</body>
If target="_blank", the link will open in
</html>
a new browser window.
Example
<!DOCTYPE html>
Put the <img> tag within the <a> tag to
<html> use an image as a link.
<body>
</a>
</body>
</html>
Button as a Link
1121
Example
# Output:
GOOGLE
<!DOCTYPE html>
<body>
</body>
</html>
Link Titles
• The title attribute specifies extra information about an element. The information is most often shown
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html> # Output:
Visit GOOGLE
Go to GOOGLE.com
1122
915
HTML JavaScript
Example
The use of unique HTML tag properties
<body>
• The <script> element either contains script statements, or it points to an external script file
• Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
• To select an HTML element, JavaScript most often uses the document.getElementById() method.
• This JavaScript example writes "Albert Einstein" into an HTML element with id="mytxt":
Example
<!DOCTYPE html>
1123
916
<html>
<body>
# Output:
<script>
</script>
</body>
</html>
• HTML bookmarks are used to allow readers to jump to specific parts of a Web page.
• Bookmarks can be useful if a webpage is very long.
Example
<!DOCTYPE html>
<html>
<body>
The use of "href" attribute to link to the bookmark
1124
916
<h2> Chapter 3 </h2>
1125
916
<p> This chapter explains behavioral ecology </p>
1126
916
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head> # Output:
<style>
GOOGLE
a {
}
(On hover)
a:hover {
color: red;
background-color: yellow;
text-decoration: underline;
</style>
</head>
<body>
</body>
</html>
1127
916
Link Buttons
Example
<!DOCTYPE html>
<html>
<head>
# Output:
<style>
a { GOOGLE
background-color: #89CFF0;
color: black;
GOOGLE
padding: 15px 25px;
text-decoration: none;
display: inline-block;
} (On hover)
a:hover {
background-color: green;
color: white;
</style>
</head>
<body>
</body>
</html>
1128
HTML Symbols
! " #
	 

$
$
%
%
&
& &
'
'
(
(
)
)
*
* *
+
+
,
,
.
.
/
/
:
:
;
;
<
< <
=
=
>
> >
?
?
@
@
[
[ [
\
\
]
] ]
^
^
_
_
`
`
{
{ {
`
1129
|
| |
}
} }
¡
¡
¢
¢
|  
£
£
¤
¤
¥
¥
¦
¦
§
§
¨
¨ ¨
©
© ©
ª
ª
«
«
¬¬
¨ ¨
® ¯ ° ±
­
²
²
³
³
´
´
µ
µ
¶
¶
´
·
· ·
¸
¸ ¸
¹
¹
º
º
»
»
·
¼
¼
½
½ ½
¾¾
¿
¿
À
À
1130
Á
Á
Â
Â
Ã
Ã
ÄÄ
Å
Å
Æ
Æ
Ç
Ç
È
È
É
É
Ê
Ê
Ë
Ë
Ì
Ì
Í
Í
Î
Î
Ï
Ï
ÐÐ
Ñ
Ñ
Ò
Ò
Ó
Ó
Ô
Ô
Õ
Õ
ÖÖ
×
×
Ø
Ø
Ù
Ù
Ú
Ú
Û
Û
ÜÜ
Ý
Ý
Þ
Þ
ß
ß
à
à
á
á
â
â
ã
ã
1131
ä
ä
å
å
æ
æ
ç
ç
è
è
é
é
ê
ê
ë
ë
ì
ì
í
í
î
î
ï
ï
ð
ð
ñ
ñ
ò
ò
ó
ó
ô
ô
õ
õ
ö
ö
÷
÷ ÷
ø
ø
ù
ù
ú
ú
û
û
ü
ü
ý
ý
þ
þ
ÿ
ÿ
Ā
Ā
ā
ā
Ă
Ă
ă
ă
Ą
Ą
ą
ą
Ć
Ć
1132
ć
ć
Ĉ
Ĉ
ĉ
ĉ
Ċ
Ċ
ċ
ċ
Č
Č
č
č
Ď
Ď
ď
ď
Đ
Đ
đ
đ
Ē
Ē
ē
ē
Ė
Ė
ė
ė
Ę
Ę
ę
ę
Ě
Ě
ě
ě
Ĝ
Ĝ
ĝ
ĝ
Ğ
Ğ
ğ
ğ
ĠĠ
ġ
ġ
Ģ
Ģ
Ĥ
Ĥ
ĥ
ĥ
Ħ
Ħ
ħ
ħ
Ĩ
Ĩ
ĩ
ĩ
Ī
Ī
ī
ī
Į
Į
1133
į
į
İ
İ
ı
ı ı
IJ
IJ
ij
ij
Ĵ
Ĵ
ĵ
ĵ
Ķ
Ķ
ķ
ķ
ĸ
ĸ
Ĺ
Ĺ
ĺ
ĺ
Ļ
Ļ
ļ
ļ
Ľ
Ľ
ľ
ľ
Ŀ
Ŀ
ŀ
ŀ
Ł
Ł
ł
ł
Ń
Ń
ń
ń
Ņ
Ņ
ņ
ņ
Ň
Ň
ň
ň
ʼn
ʼn
ŊŊ
ŋ
ŋ
Ō
Ō
ō
ō
Ő
Ő
ő
ő
Œ
Œ
œ
œ
1134
Ŕ
Ŕ
ŕ
ŕ
Ŗ
Ŗ
ŗ
ŗ
Ř
Ř
ř
ř
Ś
Ś
ś
ś
Ŝ
Ŝ
ŝ
ŝ
Ş
Ş
ş
ş
Š
Š
š
š
Ţ
Ţ
ţ
ţ
Ť
Ť
ť
ť
Ŧ
Ŧ
ŧ
ŧ
Ũ
Ũ
ũ
ũ
Ū
Ū
ū
ū
Ŭ
Ŭ
ŭ
ŭ
Ů
Ů
ů
ů
Ű
Ű
ű
ű
Ų
Ų
ų
ų
Ŵ
Ŵ
ŵ
ŵ
Ŷ
Ŷ
1135
ŷ
ŷ
Ÿ
Ÿ
Ź
Ź
ź
ź
Ż
Ż
ż
ż
Ž
Ž
ž
ž
ƒ
ƒ
Ƶ
Ƶ
ǵ
ǵ
ȷ
ȷ
ˆ
ˆ
ˇ
ˇ ˇ
˘
˘ ˘
˙
˙ ˙
˚
˚
˛
˛
˜
˜
˝
˝
˜ ˝
̑
̑
̲
_
Α
Α
Β
Β
Γ
Γ
Δ
Δ
Ε
Ε
Ζ
Ζ
ΗΗ
Θ
Θ
Ι
Ι
Κ
Κ
Λ
Λ
Μ Μ
Ν Ν
1136
ΞΞ
Ο
Ο
Π Π
ΡΡ
Σ
Σ
Τ
Τ
Υ
Υ
Φ
Φ
ΧΧ
ΨΨ
Ω
Ω
α
α
β
β
γ
γ
δ
δ
ε
ϵ ϵ
ζ
ζ
η
η
θ
θ
ι
ι
ε
κ
κ
λ
λ
μμ
ν
ν
ξ
ξ
ο
ο
ππ
ρ
ρ
ς
ς ς
σ
σ
ς
τ
τ
υ
υ υ
φ
φ ϕ ϕ
χ
χ
ψψ
1137
ω
ω
ϑ
ϑ ϑ
ϒ
ϒ ϒ
ϕ
ϕ
ϖ
ϖ ϖ
ϑ
Ϝ
Ϝ
ϝ
ϝ ϝ
ϰ
ϰ ϰ
ϱ
ϱ ϱ
ϵ
ε
ϵ
϶
϶ ϶
Ё
Ё
ЂЂ
Ѓ
Ѓ
Є
Є
Ѕ
Ѕ
І
І
Ї
Ї
Ј
Ј
Љ Љ
Њ Њ
ЋЋ
Ќ
Ќ
Ў
Ў
ЏЏ
А
А
ББ
ВВ
ГГ
ДД
Е
Е
ЖЖ
ЗЗ
И И
Й Й
1138
КК
ЛЛ
М
М
НН
О
О
ПП
Р
Р
С
С
Т
Т
У
У
ФФ
ХХ
Ц
Ц
ЧЧ
Ш
Ш
Щ
Щ
Ъ
Ъ
Ы
Ы
Ь
Ь
Э
Э
ЮЮ
ЯЯ
а
а
б
б
в
в
г
г
д
д
е
е
жж
з
з
и
и
й
й
к
к
л
л
м
м
1139
н
н
о
о
п
п
р
р
с
с
т
т
у
у
фф
х
х
ц
ц
ч
ч
шш
щ
щ
ъ
ъ
ыы
ь
ь
э
э
юю
я
я
ё
ё
ђ
ђ
ѓ
ѓ
є
є
ѕ
ѕ
і
і
ї
ї
ј
ј
љљ
њњ
ћ
ћ
ќ
ќ
ў
ў
џ
џ
 
 
1140
 
 
 
 
   
  ​ ‌ ‍ ‎
  ​
​
​
​
‏
‐
‐ ‐
–
–
—
—
―
―
‖
‖ ‖
‘
‘
’
’ ’
‚
‚ ‚
“
“
‘ ’ “
”
” ”
„
„ „
†
†
‡
‡ ‡
•
• •
”
‥
‥
…
… …
‰‰
‱‱
′
′
″
″
‴
‴
‵
‵ ‵
‹
‹
›
›
1141
‾
‾
⁁
⁁
⁃
⁃
∕
⁄
⁏
⁏
⁗
⁗
  ⁠ ⁡ ⁡ ⁢ ⁢
⁣ ⁣
€
€ ⃛ ⃛ ⃜
ℂ
ℂ ℂ
℅
℅
ℊ
ℊ
ℋ
ℋ
ℌ
ℌ ℌ
ℍ
ℍ ℍ
ℋ ℋ
ℎ
ℎ
ℏ
ℏ ℏ
ℐ
ℐ ℐ
ℑ
ℑ ℑ
ℒ
ℒ ℒ
ℏ ℏ ℑ ℑ ℒ
ℓ
ℓ
ℕ
ℕ ℕ
№№
℗
℗
℘
℘ ℘
ℙ
ℙ ℙ
ℚ
ℚ ℚ
ℛ
ℛ ℛ
ℜ
ℜ ℜ ℜ
ℝ
ℝ ℝ
ℜ
1142
℞
℞
™
™ ™
ℤ
ℤ ℤ
Ω
Ω
℧℧
ℨ
ℨ ℨ
℩
℩
Å
Å
ℬ
ℬ ℬ
ℭ
ℭ ℭ
ℬ
ℯ
ℯ
ℰ
ℰ ℰ
ℱ
ℱ ℱ
ℳ
ℳ ℳ
ℴ
ℴ ℴ
ℳ ℴ
ℵ
ℵ ℵ
ℶ
ℶ
ℷ
ℷ
ℸ
ℸ
ⅅ
ⅅ
ⅅ
ⅆ
ⅆ ⅆ
ⅇ
ⅇ
ⅈ
ⅈ ⅈ
⅓
⅓
⅔
⅔
ⅇ ⅇ
⅕
⅕
⅖
⅖
⅗
⅗
⅘
⅘
⅙
⅙
⅚
⅚
⅛
⅛
⅜⅜
⅝⅝
⅞
⅞
1143
←
← ←
↑
↑ ↑
→
→ →
↓
↓ ↓
↔↔
← ← ↑ → → ↓ ↔
← ↑ → ↓ ↔
↕
↕ ↕
↖
↖
↗
↗
↘
↘ ↘
↙
↙ ↙
↕ ↖ ↗ ↘ ↙
↖ ↗
↚ ↛ ↝
↚ ↚ ↛ ↛ ↝
↞ ↞
↟
↟
↝ ↞
↠ ↠
↡
↡
↢
↢
↣
↣
↤
↤
↠ ↢ ↣ ↤
↥
↥
↦
↦ ↦
↧
↧
↩
↩
↪
↪
↥ ↦ ↧ ↩ ↪
↫
↫
↬
↬
↭ ↭
↮
↮
↰
↰ ↰
↫ ↬ ↭ ↮
↱
↱ ↱
↲
↲
↳
↳
↵
↵
↶
↶
↶
1144
↷
↷
↺
↺
↻
↻
↼
↼ ↼
↽↽
↷ ↺ ↻ ↼ ↽
↽
↾
↾
↿
↿
⇀
⇀ ⇀
⇁⇁
⇂
⇂
↾ ↿ ⇀ ⇁ ⇂
↾ ↿ ⇁ ⇂
⇃
⇃
⇄⇄
⇅
⇅
⇆⇆
⇇⇇
⇃ ⇄ ⇅ ⇆ ⇇
⇃ ⇄ ⇆
⇈
⇈ ⇈
⇉⇉
⇊
⇊
⇋
⇋
⇌
⇌
⇉ ⇊ ⇋ ⇌
⇋ ⇌
⇍
⇍ ⇍
⇎⇎
⇏
⇏ ⇏
⇐
⇐ ⇐
⇑
⇑ ⇑
⇎ ⇐ ⇑
⇒
⇒ ⇒
⇓
⇓ ⇓
⇔ ⇔
⇕
⇕ ⇕
⇖
⇖
⇒ ⇓ ⇔ ⇕
⇒ ⇔
⇔
⇗
⇗
⇘
⇘
⇙
⇙
⇚
⇚ ⇚
⇛
⇛ ⇛
1145
⇝
⇝
⇤
⇤ ⇤
⇥
⇥
⇵
⇵
⇽
⇽
⇥ ⇵
⇾
⇾
⇿⇿
∀
∀ ∀
∁
∁ ∁
∂
∂ ∂
∃
∃ ∃
∄
∄ ∄
∅
∅ ∅
∇
∇ ∇
∈
∈ ∈
∄ ∅ ∅ ∈ ∈
∉
∉ ∉
∋
∋ ∋
∌
∌ ∌
∏
∏ ∏
∐
∐ ∐
∉ ∋ ∋ ∌
∑
∑ ∑
−
−
∓
∓ ∓
∔
∔ ∔
∖
∖ ∖
∓ ∖ ∖
∖
∗
∗
∘
∘ ∘
√
√ √
∝
∝ ∝
∞
∞
∝ ∝
∝
∟∟
∠
∠ ∠
∡
∡
∢
∢
∣
∣ ∣
∡ ∣ ∣
1146
∤
∤
∥
∥ ∥
∦
∦ ∦
∧
∧ ∧
∨
∨ ∨
∤ ∥ ∦
∤ ∤ ∥ ∥ ∦
∦
∩∩
∪∪
∫
∫ ∫
∬ ∬
∭
∭ ∭
∮
∮ ∮
∯
∯
∰∰
∱
∱
∲
∲
∮ ∯ ∲
∳
∳
∴
∴ ∴
∵
∵ ∵
∶
∶
∷
∷ ∷
∳
∴ ∵
∸
∸ ∸
∺
∺
∻
∻
∼
∼ ∼ ∼
∽
∽ ∽
∼
∾
∾ ∾
∿∿
≀
≀
≁
≁ ≁
≂
≂ ≂
≀ ≀ ≂
≃
≃ ≃
≄
≄ ≄
≅
≅
≆
≆
≇
≇
≃ ≄ ≅ ≇
1147
≈
≈ ≈
≉
≉ ≉
≊
≊ ≊
≋≋
≌
≌ ≌
≈ ≈ ≉
≈ ≈
≍
≍ ≍
≎
≎ ≎
≏
≏ ≏
≐
≐ ≐
≑
≑ ≑
≎ ≏ ≐
≒
≒
≓
≓ ≓
≔
≔ ≔
≕
≕ ≕
≖
≖ ≖
≒ ≔
≗
≗ ≗
≙
≙
≚
≚
≜
≜ ≜
≟
≟ ≟
≠
≠ ≠
≡
≡ ≡
≢
≢
≤
≤ ≤
≥
≥ ≥
≢ ≥
≦
≦ ≦
≧≧
≨
≨ ≨
≩
≩ ≩
≪
≪ ≪
≦ ≧ ≪
≧
≫ ≫
≬
≬ ≬
≭
≭
≮
≮ ≮
≯
≯ ≯
≫ ≮ ≯
≫
1148
≰
≰ ≰
≱
≱
≲
≲ ≲
≳
≳ ≳
≴
≴ ≴
≰ ≱ ≲ ≳
≱
≵
≵
≶
≶ ≶
≷
≷ ≷
≸
≸
≹
≹
≵ ≶ ≷ ≸ ≹
≺
≺ ≺ ≺
≻
≻ ≻ ≻
≼
≼
≽
≽
≾
≾ ≾
≼ ≽ ≾
≼ ≽
≿
≿ ≿
⊀
⊀ ⊀
⊁
⊁ ⊁
⊂
⊂ ⊂
⊃
⊃ ⊃
≿ ⊀ ⊁ ⊃
⊄
⊄
⊅
⊅
⊆
⊆ ⊆
⊇
⊇ ⊇
⊈
⊈ ⊈
⊆ ⊇ ⊈
⊉
⊉ ⊉
⊊
⊊ ⊊
⊋
⊋ ⊋
⊍
⊍
⊎
⊎ ⊎
⊉
⊏
⊏ ⊏
⊐
⊐
⊑
⊑
⊒
⊒
⊓
⊓
⊏ ⊐ ⊑ ⊒ ⊓
⊐ ⊑ ⊒
1149
⊔
⊔ ⊔
⊕
⊕ ⊕
⊖
⊖ ⊖
⊗
⊗ ⊗
⊘⊘
⊙
⊙ ⊙
⊚
⊚ ⊚
⊛
⊛ ⊛
⊝
⊝ ⊝
⊞
⊞ ⊞
⊟
⊟ ⊟
⊠
⊠ ⊠
⊡
⊡ ⊡
⊢
⊢ ⊢
⊣
⊣ ⊣
⊤
⊤ ⊤
⊥
⊥ ⊥ ⊥
⊧
⊧
⊨
⊨
⊩
⊩
⊥ ⊨
⊪
⊪
⊫
⊫
⊬
⊬
⊭
⊭
⊮
⊮
⊯
⊯
⊰
⊰
⊲⊲
⊳
⊳
⊴⊴
⊲ ⊳ ⊴
⊲ ⊳ ⊴
⊵
⊵
⊶⊶
⊷⊷
⊸
⊸ ⊸
⊹
⊹
⊵
⊵
1150
⊺
⊺ ⊺
⊻
⊻
⊽
⊽
⊾
⊾
⊿
⊿
⋀
⋀ ⋀
⋁
⋁ ⋁ ⋁
⋂
⋂ ⋂
⋃
⋃ ⋃
⋄
⋄ ⋄
⋀ ⋂ ⋃ ⋄
⋅
⋅
⋆
⋆ ⋆
⋇
⋇
⋈
⋈
⋉
⋉
⋇
⋊
⋊
⋋
⋋
⋌
⋌
⋍
⋍ ⋍
⋎
⋎ ⋎
⋋ ⋌
⋏
⋏ ⋏
⋐
⋐ ⋐
⋑
⋑ ⋑
⋒
⋒
⋓
⋓
⋔
⋔ ⋔
⋕
⋕
⋖
⋖ ⋖
⋗
⋗ ⋗
⋘ ⋘
⋙
⋙ ⋙
⋚⋚
⋛
⋛ ⋛
⋞
⋞ ⋞
⋟
⋟ ⋟
⋚ ⋛
⋚
1151
⋠
⋠
⋡
⋡
⋢
⋢
⋣
⋣
⋦
⋦
⋠ ⋡ ⋢ ⋣
⋧
⋧
⋨
⋨ ⋨
⋩
⋩ ⋩
⋪
⋪
⋫⋫
⋪ ⋫
⋪ ⋫
⋬
⋬
⋭
⋭
⋮
⋮
⋯
⋯
⋰
⋰
⋬ ⋭
⋬ ⋭
⋱
⋱
⋲
⋲
⋳
⋳
⋴
⋴
⋵
⋵
⋶
⋶
⋷
⋷
⋹
⋹
⋺⋺
⋻
⋻
⋼
⋼
⋽
⋽
⋾
⋾
⌅
⌅ ⌅
⌆
⌆
⌆
⌈
⌈ ⌈
⌉
⌉ ⌉
⌊
⌊ ⌊
⌋
⌋ ⌋
⌌ ⌌
⌎ ⌏ 1152
⌍ ⌍
⌎ ⌎
⌏⌏
⌐
⌐
⌒
⌒
⌓
⌓
⌕
⌕
⌖
⌖
⌜
⌜ ⌜
⌝
⌝ ⌝
⌞
⌞ ⌞
⌟
⌟ ⌟
⌢
⌢ ⌢
⌣
⌣ ⌣ ⌭
⌮
⌶
⌶
⌽⌽
⌿
⌿
⍼
⍼
⎰
⎰ ⎰
⎱
⎱ ⎱
⎴
⎴ ⎴
⎵
⎵ ⎵
⎶
⎶
⏜
⏜
⏝ ⏞
⏞
⏟ ⏢
⏝
⏟
⏧
␣
␣
Ⓢ
Ⓢ Ⓢ
─
─
│
│
─
1153
┌
┌
┐
┐
└
└
┘
┘
├
├
┤
┤
┬
┬
┴
┴
┼
┼
═
═
║
║
╒
╒
╓
╓
╔
╔
╕
╕
╖
╖
╗
╗
╘
╘
╙
╙
╚
╚
╛
╛
╜
╜
╝
╝
╞
╞
╟
╟
╠
╠
╡
╡
╢
╢
╣
╣
╤
╤
╥
╥
╦
╦
╧
╧
╨
╨
╩
╩
1154
╪
╪
╫
╫
╬
╬
▀
▀
▄
▄
█
█
░
░
▒
▒
▓
▓
□
□ □
□
▪
▪ ▪
▫
▫
▭▭
▮
▮
▱▱
▪
▪
△
△
▴
▴
▵
▵ ▵
▸
▸
▹
▹ ▹
△ ▴ ▸
▽
▽
▾
▾
▿
▿ ▿
◂
◂
◃
◃ ◃
▽ ▾ ◂
◊
◊ ◊
○
○
◬
◬
◯
◯ ◯
◸
◸
◹
◹
◺
◺
◻
◻
◼
◼
★
★ ★
1155
☆☆
☎☎
♀
♀
♂♂
♠
♠ ♠
♣
♣ ♣
♥
♥ ♥
♦
♦ ♦
♪
♪
♭
♭
♮
♮ ♮
♯
♯
✓
✓ ✓
✗
✗
✠
✠ ✠
✶✶
❘
❘
❲
❲
❳
❳
⟦
⟦
⟦
⟧
⟧
⟨
⟨
⟩
⟩
⟪
⟪
⟫
⟫
⟧ ⟨ ⟩
⟨ ⟩
⟬
⟬
⟭
⟭
⟵ ⟵
⟶ ⟶
⟷ ⟷
⟵ ⟶ ⟷
⟵ ⟶ ⟷
⟸ ⟸
⟹ ⟹
⟺ ⟺
⟼
⟼ ⟼
⟿
⟿
⟸ ⟹ ⟺
⟸ ⟹ ⟺
1156
⤂
⤂
⤃
⤃
⤄⤄
⤅ ⤅
⤌⤌
⤍
⤍ ⤍
⤎⤎
⤏
⤏ ⤏
⤐
⤐ ⤐
⤑
⤑
⤒
⤒
⤓
⤓
⤖⤖
⤙
⤙
⤚
⤚
⤛
⤛
⤜
⤜
⤝
⤝
⤞
⤞
⤟
⤟
⤠
⤠
⤣
⤣
⤤
⤤
⤥
⤥ ⤥
⤦
⤦ ⤦
⤧
⤧
⤨
⤨ ⤨
⤩
⤩ ⤩
⤪
⤪
⤳⤳
⤵
⤵
⤶
⤶
⤷
⤷
⤸
⤸
⤹
⤹
1157
⤼
⤼
⤽
⤽
⥅
⥅
⥈
⥈
⥉
⥉
⥊
⥊
⥋
⥋
⥎
⥎
⥏
⥏
⥐
⥐
⥑
⥑
⥒
⥒
⥓
⥓
⥔
⥔
⥕
⥕
⥖
⥖
⥗
⥗
⥘
⥘
⥙
⥙
⥚
⥚
⥛
⥛
⥜
⥜
⥝
⥝
⥞
⥞
⥟
⥟
⥠
⥠
⥡
⥡
⥢
⥢
⥣
⥣
⥤⥤
⥥
⥥
⥦
⥦
⥧
⥧
⥨
⥨
⥩
⥩
1158
⥪
⥪
⥫
⥫
⥬
⥬
⥭
⥭
⥮
⥮
⥮
⥯
⥯
⥰
⥰
⥱⥱
⥲
⥲
⥳
⥳
⥯
⥴
⥴
⥵
⥵
⥶
⥶
⥸
⥸
⥹
⥹
⥻
⥻
⥼
⥼
⥽
⥽
⥾
⥾
⥿
⥿
⦅
⦅
⦆
⦆
⦋
⦋
⦌
⦌
⦍
⦍
⦎
⦎
⦏
⦏
⦐
⦐
⦑
⦑
⦒
⦒
⦓
⦓
⦔
⦔
⦕
⦕
⦖
⦖
⦚
⦚
1159
⦜
⦜
⦝
⦝
⦤
⦤
⦥
⦥
⦦
⦦
⦧
⦧
⦨
⦨
⦩
⦩
⦪
⦪
⦫
⦫
⦬
⦬
⦭
⦭
⦮
⦮
⦯
⦯
⦰
⦰
⦱
⦱
⦲
⦲
⦳
⦳
⦴
⦴
⦵⦵
⦶ ⦶
⦷ ⦷
⦹⦹
⦻
⦻
⦼⦼
⦾⦾
⦿⦿
⧀ ⧀
⧁ ⧁
⧂
⧂
⧃ ⧃
⧄⧄
⧅
⧅
⧉⧉
⧍
⧍
1160
⧎
⧎
⧏
⧏
⧐
⧐
⧚
∽̱
⧜
⧜
⧝
⧝
⧞
⧞
⧣
⧣
⧤
⧤
⧥
⧥
⧫
⧫ ⧫
⧴
⧴
⧶
⧶
⨀
⨀ ⨀
⨁
⨁ ⨁
⨂
⨂ ⨂
⨄
⨄ ⨄
⨆
⨆ ⨆
⨌
⨌ ⨌
⨍
⨍
⨐
⨐
⨑
⨑
⨒
⨒
⨓
⨓
⨔
⨔
⨕
⨕
⨖
⨖
⨗
⨗
⨢
⨢
⨣
⨣
⨤
⨤
⨥
⨥
⨦
⨦
⨧
⨧
⨩
⨩
1161
⨪
⨪
⨭
⨭
⨮
⨮
⨯
⨯
⨰
⨰
⨱
⨱
⨳
⨳
⨴
⨴
⨵
⨵
⨶
⨶
⨷
⨷
⨸⨸
⨹
⨹
⨺
⨺
⨻
⨻
⨼
⨼ ⨼
⨿
⨿
⩀
⩀
⩂⩂
⩃⩃
⩄
⩄
⩅
⩅
⩆
⩆
⩇
⩇
⩈
⩈
⩉
⩉
⩊
⩊
⩋
⩋
⩌
⩌
⩍
⩍
⩐
⩐
⩓
⩓
⩔⩔
⩕
⩕
⩖⩖
1162
⩗
⩗
⩘
⩘
⩚
⩚
⩛⩛
⩜
⩜
⩝⩝
⩟
⩟
⩦
⩦
⩪
⩪
⩭
⩭
⩮
⩮
⩯
⩯
⩰⩰
⩱
⩱
⩲
⩲
⩳
⩳
⩴⩴
⩵ ⩵
⩷
⩷ ⩷
⩸
⩸
⩹
⩹
⩺
⩺
⩻
⩻
⩼
⩼
⩽
⩽ ⩽
⩽
⩾ ⩾
⩿
⩿
⪀
⪀
⪁
⪁
⪂
⪂
⩾
⩾
⪃
⪃
⪄
⪄
⪅
⪅ ⪅
⪆
⪆ ⪆
⪇
⪇ ⪇
1163
⪋ ⪌
⪈
⪈ ⪈
⪉
⪉ ⪉
⪊
⪊ ⪊
⪋
⪋ ⪋
⪌
⪌ ⪌
⪍
⪍
⪎
⪎
⪏
⪏
⪐
⪐
⪑⪑
⪒⪒
⪓
⪓
⪔
⪔
⪕
⪕ ⪕
⪖
⪖ ⪖
⪗
⪗
⪘
⪘
⪙⪙
⪚⪚
⪝⪝
⪞⪞
⪟
⪟
⪠
⪠
⪡
⪡
⪢
⪢
⪤ ⪤
⪥ ⪥
⪦
⪦
⪧
⪧
⪨
⪨
⪩
⪩
⪪⪪
⪫⪫
⪬
⪬
⪭⪭
1164
⪮
⪮
⪯
⪯ ⪯
⪰
⪰ ⪰
⪳⪳
⪴
⪴
⪯ ⪰
⪵
⪵ ⪵
⪶
⪶ ⪶
⪷
⪷ ⪷
⪸
⪸ ⪸
⪹
⪹ ⪹
⪺
⪺ ⪺
⪻ ⪻
⪼ ⪼
⪽
⪽
⪾
⪾
⪿
⪿
⫀
⫀
⫁
⫁
⫂
⫂
⫃
⫃
⫄
⫄
⫅
⫅ ⫅
⫆
⫆ ⫆
⫇
⫇
⫈
⫈
⫋
⫋ ⫋
⫌
⫌ ⫌
⫏
⫏
⫐
⫐
⫑
⫑
⫒
⫒
⫓
⫓
⫔
⫔
⫕
⫕
⫖
⫖
1165
⫗ ⫗
⫘
⫘
⫙
⫙
⫚
⫚
⫛⫛
⫤
⫤
⫦
⫦
⫧
⫧
⫨
⫨
⫩
⫩
⫤
⫫
⫫
⫬⫬
⫭
⫭
⫮
⫮
⫯
⫯
⫰
⫰
⫱
⫱
⫲
⫲
⫳
⫳
⫽
⫽
ff
ff
fi
fi
fl
fl
ffi
ffi
ffl
ffl
ᵉ𝒜
ᵉ
𝒞
ᵊ
𝒟
ᵊ
𝒢
ᵊ
𝒥
ᵋ𝒦
ᵊ𝒩
ᵋ
𝒪
ᵌ
𝒫
ᵍ
𝒬
1166
ᵊ
𝒮
ᵋ
𝒯
ᵌ
𝒰
ᵍ
𝒱
ᵎ
𝒲
ᵏ
𝒳
ᵐ
𝒴
ᵑ
𝒵
ᵒ
𝒶
ᵓ
𝒷
ᵔ
𝒸
ᵕ
𝒹
ᵋ
𝒻
ᵋ
𝒽
ᵌ
𝒾
ᵍ
𝒿
ᵎ
𝓀
ᵌ
𝓁
ᵌ
𝓂
ᵍ
𝓃
ᵌ
𝓅
ᵍ
𝓆
ᵎ
𝓇
ᵏ
𝓈
ᵐ
𝓉
ᵑ
𝓊
ᵒ
𝓋
ᵓ
𝓌
ᵔ
𝓍
ᵕ
𝓎
ᵖ
𝓏
ᵐ
𝔄
ᵑ
𝔅
ᵐ
𝔇
ᵑ
𝔈
1167
ᵒ
𝔉
ᵓ
𝔊
ᵐ
𝔍
ᵑ
𝔎
ᵒ
𝔏
ᵓ
𝔐
ᵔ
𝔑
ᵕ
𝔒
ᵖ
𝔓
ᵗ
𝔔
ᵑ
𝔖
ᵒ
𝔗
ᵓ
𝔘
ᵔ
𝔙
ᵕ
𝔚
ᵖ
𝔛
ᵗ
𝔜
ᵑ
𝔞
ᵒ
𝔟
ᵓ
𝔠
ᵔ
𝔡
ᵕ
𝔢
ᵖ
𝔣
ᵗ
𝔤
ᵘ
𝔥
ᵙ
𝔦
ᵚ
𝔧
ᵛ
𝔨
ᵜ
𝔩
ᵝ
𝔪
ᵞ
𝔫
ᵟ
𝔬
ᵠ
𝔭
ᵡ
𝔮
ᵢ
𝔯
1168
ᵣ
𝔰
ᵤ
𝔱
ᵥ
𝔲
ᵦ
𝔳
ᵧ
𝔴
ᵨ
𝔵
ᵩ
𝔶
ᵪ
𝔷
ᵫ
𝔸
ᵬ
𝔹
ᵓ
𝔻
ᵔ
𝔼
ᵕ
𝔽
ᵖ
𝔾
ᵔ
𝕀
ᵕ
𝕁
ᵖ
𝕂
ᵗ
𝕃
ᵘ
𝕄
ᵔ
𝕆
ᵔ
𝕊
ᵕ
𝕋
ᵖ
𝕌
ᵗ
𝕍
ᵘ
𝕎
ᵙ
𝕏
ᵚ
𝕐
ᵕ
𝕒
ᵖ
𝕓
ᵗ
𝕔
ᵘ
𝕕
ᵙ
𝕖
ᵚ
𝕗
ᵛ
𝕘
ᵜ
𝕙
1169
ᵝ
𝕚
ᵞ
𝕛
ᵟ
𝕜
ᵠ
𝕝
ᵡ
𝕞
ᵢ
𝕟
ᵣ
𝕠
ᵤ
𝕡
ᵥ
𝕢
ᵦ
𝕣
ᵧ
𝕤
ᵨ
𝕥
ᵩ
𝕦
ᵪ
𝕧
ᵫ
𝕨
ᵬ
𝕩
ᵭ
𝕪
ᵮ
𝕫
1170
<!DOCTYPE html>
<html>
<body>
<script>
console.log(/xyz/.test("vwxyz"));
// Output: true
This program will provide us a Boolean output
indicating whether the string contains a
console.log(/xyz/.test("vxwyz")); match to the expression's pattern
// Output: false
</script>
<script>
console.log(encodeURIComponent("How?"));
// Output: How%3F
console.log(decodeURIComponent("How%3F"));
// Output: How?
</script>
1171
<script>
# Output:
for(let x = 1; x < 5; x++) {
1 *^@^*
console.log(x + " *^@^*"); 2 *^@^*
} 3 *^@^*
4 *^@^*
</script>
<script>
let x = "Albert";
# Output:
console.log("Hi " + x);
Hi Albert
if(x.length > 5) {
Elsa
console.log("Elsa");
</script>
<script>
let x = "Albert";
document.write("Elsa");
</script>
1172
<script>
let x = true;
let y = true;
let z = true;
if (x) {
# Output:
} else if (y) {
console.log("Elsa Einstein");
} else if (z) {
} else {
console.log("David Einstein");
</script>
<script>
let x = false;
let y = true;
let z = true;
# Output:
if (x) {
console.log("Albert Einstein"); Elsa Einstein
} else if (y) {
console.log("Elsa Einstein");
} else if (z) {
console.log("Hans Albert Einstein");
} else {
console.log("David Einstein");
}
</script>
1173
<script>
let x = false;
let y = false;
let z = true;
if (x) { # Output:
console.log("Albert Einstein"); Hans Albert Einstein
} else if (y) {
console.log("Elsa Einstein");
} else if (z) {
console.log("Hans Albert Einstein");
} else {
console.log("David Einstein");
}
</script>
<script>
let x = false;
let y = false;
let z = false;
if (x) { # Output:
console.log("Albert Einstein");
David Einstein
} else if (y) {
console.log("Elsa Einstein");
} else if (z) {
} else {
console.log("David Einstein");
</script>
1174
Document object model (DOM):
The way that HTML elements are arranged and maintained by web browsers
<script>
console.log(x.split(/\s*,\s*/));
var i = '|x|y|z|'.split(/\|/);
console.log(i);
</script>
<script>
// Output: true
// Output: true
</script>
1175
<script>
</script>
<script>
</script>
1176
<script>
// 1 + 1 = 2
</script>
1177
<script>
</script>
a == 0 && b == 0
(a == 0 && b == 0) || !(c == 0)
<script>
let a = .3 - .2;
let b = .2 - .1;
console.log(a == b); // false: the 2 values are not the same
console.log(a == .1); // false: .3 -.2 is not equal to .1
console.log(b == .1); // true: .2 -.1 is equal to .1
</script>
1178
<script>
</script>
[] → An empty array
<script>
x.length = 3
x.length = 0
</script>
1179
<script>
</script>
<script>
</script>
1180
<script>
let i = [];
for(x=1; x<10; x++) {
<script>
if (x % 2 === 0)
var i = 2; // starting condition
i.push(x*x);
while(i > 1 && i < 10) {
}
i = i + 2; // 2 steps forward
console.log(i);
i = i - 1; // 1 step back
console.log(i);
// Output: [ 4, 16, 36, 64 ]
}
</script>
</script>
# Output:
<script>
3
var x = 589; 4
var y = Number("55"); 5
const a = 15;
const b = 13 - -a;
console.log(b); // Output: 28
</script>
1181
<script>
<script>
</script>
<script>
const x = false;
const i = x ? "Albert" : "Elsa";
console.log(i); // Output: Elsa
Aggregation:
</script>
The ability to enclose one object
1182
<script>
const z = y - x;
console.log(z);
const w = z/1000/60/60/24;
console.log(w);
console.log(JSON.parse('5496'));
// Output: 5496
</script>
1183
HTML Video
The HTML <video> element specifies a standard way to embed a video in a web page.
Example
<!DOCTYPE html>
<html>
Video controls like
<body> play, pause, and volume
are added through the
<video width = "300" height = "200" controls>
controls attribute
<source src="mov.mp4" type="video/mp4">
</video>
</body>
</html>
<!DOCTYPE html>
We employ the "autoplay"
<html>
attribute in order to play
<body> a video automatically
</video>
</html>
1184
<!DOCTYPE html>
</video>
</html>
The web browser support for the different video formats is:
1185
<!DOCTYPE html>
</video>
</body>
</html>
HTML Audio
The HTML <audio> element specifies a standard way to embed audio in a web page.
Example
<!DOCTYPE html>
Audio controls like play, pause, and volume
<html>
are added through the controls attribute
<body>
<audio controls>
</audio>
To play an audio file in HTML, we use
</body>
the <audio> element
</html>
1186
934
<!DOCTYPE html>
</audio>
</body>
</html>
<!DOCTYPE html>
To enable automatic playback
<html> of a audio (but muted), we add
</audio>
The web browser support for the different audio formats is:
1187
934
Browser MP3 WAV OGG
<!DOCTYPE html>
<html>
<body>
</iframe>
</body>
</html>
1188
934
<!DOCTYPE html>
The <embed> element does not have a closing tag. It is
<html>
used to include "index.html" in HTML Document
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<!-- Unordered List with Circle Bullets -->
<ul style="list-style-type: circle;">
# Output:
<li> Albert </li>
<li> Elsa </li> o Albert
<li> David </li>
o Elsa
</ul>
</body> o David
</html>
1189
934
<!DOCTYPE html>
<html>
<body>
<!DOCTYPE html>
<html>
<body>
1190
934
<!DOCTYPE html>
<html>
<body>
<!DOCTYPE html>
<html>
<body>
<ol type="1">
<li> Albert </li>
<li> Elsa </li>
# Output:
<li> David </li>
</ol> 1. Albert
2. Elsa
</body> 3. David
</html>
1191
934
<!DOCTYPE html>
<html>
<body>
<ol type="A">
<li> Albert </li>
<li> Elsa </li>
# Output:
<li> David </li>
</ol> A. Albert
B. Elsa
</body> C. David
</html>
<!DOCTYPE html>
<html>
<body>
<ol type="a">
<li> Albert </li>
<li> Elsa </li>
# Output:
<li> David </li> a. Albert
</ol> b. Elsa
c. David
</body>
</html>
1192
934
<!DOCTYPE html>
<html>
<body>
<ol type="I">
<li> Albert </li>
<li> Elsa </li> # Output:
<li> David </li>
I. Albert
</ol>
II. Elsa
III. David
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<ol type="i">
<li> Albert </li>
<li> Elsa </li> # Output:
<li> David </li>
</ol>
i. Albert
ii. Elsa
1193
934
<!DOCTYPE html>
<html>
<body>
<ul>
<li> Alan Turing </li>
<li> Albert Einstein
<ul>
A Nested List
<li> Elsa Einstein </li>
(List inside list)
<li> David Einstein </li>
</ul>
</li>
<li> Charles Darwin </li>
# Output:
</ul>
Alan Turing
Albert Einstein
</body>
o Elsa Einstein
</html>
o David Einstein
Charles Darwin
<!DOCTYPE html>
<html>
<body>
<!-- Styling a <div> element -->
<div style="background-color: green; color: white; padding: 20px;">
<h1> Albert Einstein </h1>
</div> # Output:
</body>
Albert Einstein
</html>
1194
934
HTML Tables
Tag Description
<table> Defines a table
Example
<table>
<tr>
<td> Albert </td> 1 Column
# Output:
</tr>
</table> Albert
<table>
<tr>
<td> Albert </td>
1 Row and 3 Columns
<td> John </td>
<td> Mary </td>
</tr> # Output:
</table>
Albert John Mary
1195
934
<table>
<tr>
<td> Albert </td>
<td> John </td>
<td> Mary </td>
</tr>
<tr>
<td> Elsa </td>
<td> Alan </td> 3 Rows and 3 Columns
<td> David </td>
</tr>
<tr> # Output:
<td> Charles </td>
<td> James </td> Albert John Mary
<td> William </td> Elsa Alan David
Charles James William
</tr>
</table>
<!DOCTYPE html>
<html>
<style>
table, tr, td {
</style>
</head>
1196
934
<body>
<script>
<table>
console.log(escape("Albert Einstein"));
<tr> // Output: Albert%20Einstein
<td> Albert </td>
<td> John </td> console.log(unescape("Albert%20Einstein"));
<td> Mary </td> // Output: Albert Einstein
</tr>
</script>
<tr>
<td> Elsa </td>
<td> Alan </td>
<td> David </td> # Output:
</tr>
Albert John Mary
<tr> Elsa Alan David
<td> Charles </td> Charles James William
<td> James </td>
<td> William </td>
</tr>
strings.
numerical information.
1197
934
<!DOCTYPE html>
<html>
<head>
A table with collapsed borders
<style>
table, tr, td {
border-collapse: collapse;
<body>
<table>
<tr>
<td> Albert </td>
<td> John </td>
<td> Mary </td>
</tr> # Output:
<tr>
<td> Elsa </td>
Albert John Mary
<td> Alan </td>
Elsa Alan David
<td> David </td>
Charles James William
</tr>
<tr>
<td> Charles </td>
<td> James </td>
<td> William </td>
</tr>
</table>
</body>
</html>
1198
934
<head>
<style>
A table with cell padding
table, tr, td {
border-collapse: collapse;
</style>
</head>
<body>
<table>
<tr>
# Output:
<td> Albert </td>
<td> John </td>
<td> Mary </td>
</tr> Albert John Mary
<tr>
<td> Elsa </td> Elsa Alan David
<td> Alan </td>
<td> David </td> Charles James William
</tr>
<tr>
<td> Charles </td>
<td> James </td>
<td> William </td>
</tr>
</table>
</body>
1199
934
<head>
<style>
table, th, td {
A table with headings
border: 2px solid black;
border-collapse: collapse;
th, td {
padding: 15px;
</style>
</head>
<body>
# Output:
<table>
<tr>
<th> Name </th>
Name Age
<th> Age </th>
</tr> Elsa 50
<tr>
<td> Elsa </td> Charles 75
<td> 50 </td>
</tr>
<tr>
<td> Charles </td>
<td> 75 </td>
</tr>
</table>
</body>
1200
934
<!DOCTYPE html>
<html>
<body>
<table>
<tr>
<th> Name </th>
<th colspan="2"> Phone number </th>
</tr>
# Output:
<tr>
<td> Elsa </td>
<td> 080-65960971 </td>
Name Phone number
<td> 080-68950991 </td>
</tr>
Elsa 080-65960971 080-68950991
</table>
</body>
</html>
1201
934
CSS
(Cascading Style Sheets)
Cascading Style Sheets, or CSS, is a language that specifies how HTML elements
should be displayed, including the layout, colours, and fonts of an HTML Document. Along with
HTML and JavaScript, CSS is a key component of the World Wide Web and a
simplistic design language made to make the process of generating appealing web pages easier.
CSS Syntax
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: red; World Wide Web Consortium (W3C)
text-align: center;
Creator of CSS
}
</style>
</head> # Output:
<body>
<h1> Albert Einstein </h1>
Albert Einstein
</body>
</html>
h1 is a selector in CSS (it points to the HTML element you want to style: <h1>).
color is a property, and red is the property value
text-align is a property, and center is the property value
1202
949
CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements we want to style.
The element selector selects HTML elements based on the element name.
Example
Here, all <h2> elements on the page will be center-aligned with a red text color.
<!DOCTYPE html>
<html>
<head>
<style>
h2 {
text-align: center;
color: red; # Output:
}
</style> Albert Einstein
</head>
Elsa Einstein
<body>
David Einstein
<h2> Albert Einstein </h2>
<h2> Elsa Einstein </h2>
<h2> David Einstein </h2>
</body>
</html>
1203
949
The id selector uses the id attribute of an HTML element to select a specific element.
Example
<!DOCTYPE html>
<html>
<head>
<style>
#my1 {
text-align: center; # Output:
color: red;
}
Albert Einstein
</style>
</head>
<body>
</body>
</html>
The class selector selects HTML elements with a specific class attribute.
Example
<!DOCTYPE html>
<html>
<head>
<style>
1204
951
.my1 {
text-align: center;
color: red;
# Output:
}
</head>
<body>
</body>
</html>
The universal selector (*) selects all HTML elements on the page.
Example
<!DOCTYPE html>
<html>
<head>
<style>
* {
text-align: center;
color: blue; # Output:
}
</style>
Albert Einstein
</head>
<body> Elsa Einstein
</body>
</html>
1205
952
The CSS Grouping Selector
The grouping selector selects all the HTML elements with the same style definitions.
Look at the following CSS code (the h1, h2, and p elements have the same style definitions):
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: red;
}
</style>
</head>
<body> # Output:
CSS Comments
Comments are used to explain the code and may help when we edit the source code at a later time.
Comments are ignored by web browsers.
A CSS comment is placed inside the <style> element and starts with /* and ends with */:
1206
952
Example
<!DOCTYPE html>
<html>
<head>
<style>
p {
}
It's a good idea to include comments in the code
/* This is
because they can make it easier to understand if
a multi-line someone reads it or if it is later reviewed.
Comment */
</style>
</head>
<body>
# Output:
<p> Albert Einstein </p>
Albert Einstein
</body>
</html>
1207
952
CSS Backgrounds
CSS background-color
Example
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: yellow; # Output:
}
</style>
Albert Einstein
</head>
<body>
</body>
</html>
Opacity / Transparency
1208
952
<!DOCTYPE html>
<html>
<head>
<style>
div {
/* Blue background with 60% opacity */
background-color: blue;
opacity: 0.6;
</style> # Output:
</head>
<body>
Albert Einstein
<div>
<h1> Albert Einstein </h1>
</div>
</body>
</html>
CSS background-image
Example
1209
952
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("img.png");
}
</style>
</head>
# Output:
<body>
Albert Einstein
<h1> Albert Einstein </h1>
</body>
</html>
Example
<!DOCTYPE html>
<html>
Set "background-repeat: repeat-x" to
<head>
repeat a background image horizontally.
<style>
body {
background-image: url("img.png");
background-repeat: repeat-x;
}
</style>
</head>
1210
952
<body>
</body>
</html>
Example
<!DOCTYPE html>
<html>
Set "background-repeat: repeat-y" to
<head>
repeat a background image vertically.
<style>
body {
background-image: url("img.png");
background-repeat: repeat-y;
}
</style>
</head>
<body>
</body>
</html>
1211
952
CSS background-repeat: no-repeat
Example
<!DOCTYPE html>
<html>
<head>
</style>
</head>
<body>
</body>
</html>
CSS background-position
The background-position property is used to specify the position of the background image.
Example
1212
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("img.png");
background-repeat: no-repeat;
background-position: right top;
}
The background image is placed in the
</style>
top-right corner of the HTML Document
</head>
<body>
</body>
</html>
Example
<style>
All the background properties in one declaration
body {
</style>
1213
962
CSS Borders
Example
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
1214
962
<p class="solid"> Albert Einstein </p>
<p class="double"> Albert Einstein </p>
<p class="groove"> Albert Einstein </p>
<p class="ridge"> Albert Einstein </p>
<p class="inset"> Albert Einstein </p>
<p class="outset"> Albert Einstein </p>
<p class="none"> Albert Einstein </p>
<p class="hidden"> Albert Einstein </p>
<p class="mix"> Albert Einstein </p>
</body>
</html>
# Output:
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
1215
962
CSS Border Width
Example
<!DOCTYPE html>
<html>
<head>
<style>
p.b1 {
border-style: solid; In the Java programming language, the word
border-width: 6px; "Final" has several different meanings:
}
Final Class: This class is not inheritable.
Final Variable: Once a value has been assigned
p.b2 { to a final variable, it cannot be changed.
border-style: solid; Final Method: This Method is irrevocable.
border-width: medium;
}
p.b3 {
border-style: dotted;
border-width: 10px;
}
p.b4 {
border-style: dotted;
border-width: thick;
}
p.b5 {
border-style: double;
border-width: 4px;
}
1216
962
p.b6{
border-style: double;
border-width: thick;
}
</style>
</head>
<body>
</body>
</html>
# Output:
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
Albert Einstein
1217
965
CSS Border Color
The border-color property is used to set the color of the four borders.
Example
<!DOCTYPE html>
<html>
A programmer can add new variables at
<head>
runtime, and variable types are changed
<style>
at runtime, which is why the JavaScript
p.b1 {
programming language is referred to be
border-style: solid;
a dynamically typed language.
border-color: blue;
}
p.b2 {
border-style: solid;
border-color: red;
}
# Output:
p.b3 {
border-style: dotted; Albert Einstein
border-color: green;
} Elsa Einstein
</style>
</head> David Einstein
<body>
</body>
</html>
1218
965
Specific Side Colors
Example
<!DOCTYPE html>
<html>
<head>
<style>
p.b1 {
border-style: solid;
border-color: green orange red yellow;
/* green top, orange right, red bottom and yellow left */
}
</style>
</head>
<body>
<p class="b1"> Albert Einstein </p>
</body>
</html>
# Output:
Albert Einstein
1219
965
HEX Values
The color of the border can be specified using a hexadecimal value (HEX):
Example
p.b1 {
border-style: solid;
RGB Values
The color of the border can be specified using a RGB value (RGB):
Example
p.b1 {
border-style: solid;
HSL Values
The color of the border can be specified using a HSL value (HSL):
Example
p.b1 {
border-style: solid;
1220
968
CSS Rounded Borders
Example
<!DOCTYPE html>
<html>
Did you know?
<head>
<style> The International Space Station uses ADA, a
p.b1 {
coding language that was created in 1980. This
border: 2px solid blue; programming language gained acceptance as an
padding: 5px;
international standard in 1995.
}
# Output:
</body>
</html> Albert Einstein
Albert Einstein
1221
968
CSS Margins
The CSS margin properties are used to create space around HTML elements, outside of any defined borders.
<!DOCTYPE html>
<html>
<head>
Margin - Shorthand Property
<style>
div {
border: 1px solid black;
margin-top: 100px;
margin-bottom: 100px;
margin: 100px 100px 150px 50px;
margin-right: 150px;
margin-left: 50px;
top margin is 100px
background-color: yellow;
right margin is 100px
}
bottom margin is 150px
</style>
left margin is 50px
</head>
<body>
<div> Elsa Einstein was the second wife and cousin of Albert Einstein. </div>
</body>
</html> This <div> element has a top margin of 100px, a right margin of
150px, a bottom margin of 100px, and a left margin of 50px.
# Output:
Elsa Einstein was the second wife and cousin of Albert Einstein.
1222
970
CSS Padding
The CSS padding properties are used to generate space around an HTML element's content, inside of
any defined.. .borders.
Example
<!DOCTYPE html>
<html>
<head>
<style>
div { Padding - Shorthand Property
border: 1px solid black;
background-color: yellow;
padding-top: 60px;
padding-right: 40px;
padding: 60px 40px 60px 70px;
padding-bottom: 60px;
padding-left: 70px;
top padding is 60px
}
right padding is 40px
</style>
bottom padding is 60px
</head>
left padding is 70px
<body>
<div> Elsa Einstein was the second wife and cousin of Albert Einstein. </div>
</body> This <div> element has a top padding of 60px, a right padding of 40px,
</html> a bottom padding of 60px, and a left padding of 70px.
# Output:
Elsa Einstein was the second wife and cousin of Albert Einstein.
1223
974
CSS Height and Width
The height and width properties are used to set the height and width of an HTML element.
Example
<!DOCTYPE html>
<html>
<head>
<style> # Output:
div {
height: 100px; Albert and Elsa Einstein.
width: 40%;
background-color: orange;
}
</style>
</head>
<body>
</body> This <div> element has a height of 100px and a width of 40%.
</html>
<style>
div {
height: 100px;
width: 400px;
background-color: orange;
}
</style>
Example
1224
977
CSS Text
Text Alignment
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
}
h2 { #Output:
text-align: left;
} Albert Einstein
h3 {
Elsa Einstein
text-align: right;
David Einstein
}
</style>
</head>
1225
977
<!DOCTYPE html> When the text-align property is set to "justify",
<html> every line is widened to the same width, and the
<head> left and right margins are aligned evenly.
<style>
div {
border: 1px solid black;
padding: 20px; # Output:
width: 200px;
height: 100px; Elsa Einstein was the second
text-align: justify; wife and cousin of Albert
background-color: yellow; Einstein
}
</style>
</head>
<body>
<div>
Elsa Einstein was the second wife and cousin of Albert Einstein
</div>
</body>
</html>
<style> # Output:
div {
border: 1px solid black;
Elsa Einstein was the second
padding: 20px; wife and cousin of Albert
width: 200px; Einstein
height: 100px;
background-color: yellow;
}
</style>
1226
981
Text Decoration
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
} # Output:
h3 {
____________________
text-decoration: underline; Albert Einstein
}
Elsa Einstein
p.mytxt { David Einstein
text-decoration: overline underline; ___________________________________________________
} Elsa Einstein was the second wife and cousin of Albert Einstein.
</style>
</head>
Text Transformation
<body>
The text-transform propertyis used to specify uppercase and lowercase letters in a text.
<h1> Albert Einstein </h1>
<h2> Elsa Einstein </h2>
<h3> David Einstein </h3>
<p class="mytxt"> Elsa Einstein was the second wife and cousin of Albert Einstein. </p>
Example
</body>
</html>
1227
981
Text Transformation
The text-transform property is used to specify uppercase and lowercase letters in a text.
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1.uppercase {
text-transform: uppercase;
}
h1.lowercase {
text-transform: lowercase;
}
h1.capitalize { # Output:
text-transform: capitalize;
ALBERT EINSTEIN
}
</style> albert einstein
<body>
</body>
</html>
1228
981
Text Indentation
The text-indent property is used to specify the indentation of the first line of a text.
Example
<!DOCTYPE html>
<html>
<head>
<style>
p {
text-indent: 60px;
}
</style>
</head>
<body>
</body>
</html>
# Output:
Albert Einstein was a German-born theoretical physicist, widely acknowledged to be one of
the greatest and most influential physicists of all time. Einstein is best known for developing the
theory of relativity, but he also made important contributions to the development of the theory of
quantum mechanics.
1229
981
Letter Spacing
The letter-spacing property is used to specify the space between the characters in a text.
Example
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
letter-spacing: 7px;
}
h2 {
letter-spacing: -3px;
}
</style>
</head>
<body>
</body>
</html>
# Output:
Albert Einstein
AlbertEinstein
1230
981
Line Height
Example
<!DOCTYPE html>
<html>
<head>
<style>
p.l1 {
line-height: 0.8;
} # Output:
<p class="l1">
Albert Einstein was a German-born theoretical physicist. <br>
Best known for developing the theory of relativity. <br>
</p>
<p class="l2">
Albert Einstein was a German-born theoretical physicist. <br>
Best known for developing the theory of relativity. <br>
</p>
</body>
</html>
1231
Word Spacing
The word-spacing property is used to specify the space between the words in a text.
Text Shadow
<!DOCTYPE html>
<html>
The text-shadow property adds shadow to text.
<head>
<!DOCTYPE html>
<style> <html>
Example
<head>
p.l1 { <style>
h1 {
word-spacing: 12px; text-shadow: 2px 2px blue;
} }
</style>
</head>
p.l2 {
?
<body>
word-spacing: -3px;
} <h1> Albert </h1>
</body>
</style> </html>
</head>
<body>
<p class="l1"> Elsa Einstein was the second wife and cousin of Albert Einstein. </p>
<p class="l2"> Elsa Einstein was the second wife and cousin of Albert Einstein. </p>
</body>
</html>
# Output:
Elsa Einstein was the second wife and cousin of Albert Einstein.
ElsaEinsteinwasthe secondwifeandcousinofAlbertEinstein
1232
986
Font Awesome Text Icons
fa-500px fa-arrows
fa-adjust fa-arrows-alt
fa-adn fa-arrows-h
fa-align-center fa-arrows-v
fa-align-justify fa-asterisk
fa-align-left fa-at
fa-align-right fa-automobile
fa-amazon fa-backward
fa-ambulance fa-balance-scale
fa-anchor fa-ban
fa-android fa-bank
fa-angellist fa-bar-chart
fa-angle-double-down fa-bar-chart-o
fa-angle-double-left fa-barcode
fa-angle-double-right fa-bars
fa-angle-double-up fa-battery-0
fa-angle-down fa-battery-1
fa-angle-left fa-battery-2
fa-angle-right fa-battery-3
fa-angle-up fa-battery-4
fa-apple fa-battery-empty
fa-archive fa-battery-full
fa-area-chart fa-battery-half
fa-arrow-circle-down fa-battery-quarter
fa-arrow-circle-left fa-battery-three-quarters
fa-arrow-circle-o-down fa-bed
fa-arrow-circle-o-left fa-beer
fa-arrow-circle-o-right fa-behance
fa-arrow-circle-o-up fa-behance-square
fa-arrow-circle-right fa-bell
fa-arrow-circle-up fa-bell-o
fa-arrow-down fa-bell-slash
fa-arrow-left fa-bell-slash-o
fa-arrow-right fa-bicycle
fa-arrow-up fa-binoculars
1233
fa-birthday-cake fa-caret-right
fa-bitbucket fa-caret-square-o-down
fa-bitbucket-square fa-caret-square-o-left
fa-bitcoin fa-caret-square-o-right
fa-black-tie fa-caret-square-o-up
fa-bluetooth fa-caret-up
fa-bluetooth-b fa-cart-arrow-down
fa-bold fa-cart-plus
fa-bolt fa-cc
fa-bomb fa-cc-amex
fa-book fa-cc-diners-club
fa-bookmark fa-cc-discover
fa-bookmark-o fa-cc-jcb
fa-briefcase fa-cc-mastercard
fa-btc fa-cc-paypal
fa-bug fa-cc-stripe
fa-building fa-cc-visa
fa-building-o fa-certificate
fa-bullhorn fa-chain
fa-bullseye fa-chain-broken
fa-bus fa-check
fa-buysellads fa-check-circle
fa-cab fa-check-circle-o
fa-calculator fa-check-square
fa-calendar fa-check-square-o
fa-calendar-check-o fa-chevron-circle-down
fa-calendar-minus-o fa-chevron-circle-left
fa-calendar-o fa-chevron-circle-right
fa-calendar-plus-o fa-chevron-circle-up
fa-calendar-times-o fa-chevron-down
fa-camera fa-chevron-left
fa-camera-retro fa-chevron-right
fa-car fa-chevron-up
fa-caret-down fa-child
fa-caret-left fa-chrome
1234
fa-circle fa-crop
fa-circle-o fa-crosshairs
fa-circle-o-notch fa-css3
fa-circle-thin fa-cube
fa-clipboard fa-cubes
fa-clock-o fa-cut
fa-clone fa-cutlery
fa-close fa-dashboard
fa-cloud fa-dashcube
fa-cloud-download fa-database
fa-cloud-upload fa-dedent
fa-cny fa-delicious
fa-code fa-desktop
fa-code-fork fa-deviantart
fa-codepen fa-diamond
fa-codiepie fa-digg
fa-coffee fa-dollar
fa-cog fa-dot-circle-o
fa-cogs fa-download
fa-columns fa-dribbble
fa-comment fa-dropbox
fa-comment-o fa-drupal
fa-commenting fa-edge
fa-commenting-o fa-edit
fa-comments fa-eject
fa-comments-o fa-ellipsis-h
fa-compass fa-ellipsis-v
fa-compress fa-empire
fa-connectdevelop fa-envelope
fa-contao fa-envelope-o
fa-copy fa-envelope-square
fa-copyright fa-eraser
fa-creative-commons fa-eur
fa-credit-card fa-euro
fa-credit-card-alt fa-exchange
1235
fa-exclamation fa-file-video-o
fa-exclamation-circle fa-file-word-o
fa-exclamation-triangle fa-file-zip-o
fa-expand fa-files-o
fa-expeditedssl fa-film
fa-external-link fa-filter
fa-external-link-square fa-fire
fa-eye fa-fire-extinguisher
fa-eye-slash fa-firefox
fa-eyedropper fa-flag
fa-facebook fa-flag-checkered
fa-facebook-f fa-flag-o
fa-facebook-official fa-flash
fa-facebook-square fa-flask
fa-fast-backward fa-flickr
fa-fast-forward fa-floppy-o
fa-fax fa-folder
fa-feed fa-folder-o
fa-female fa-folder-open
fa-fighter-jet fa-folder-open-o
fa-file fa-font
fa-file-archive-o fa-fonticons
fa-file-audio-o fa-fort-awesome
fa-file-code-o fa-forumbee
fa-file-excel-o fa-forward
fa-file-image-o fa-foursquare
fa-file-movie-o fa-frown-o
fa-file-o fa-futbol-o
fa-file-pdf-o fa-gamepad
fa-file-photo-o fa-gavel
fa-file-picture-o fa-gbp
fa-file-powerpoint-o fa-ge
fa-file-sound-o fa-gear
fa-file-text fa-gears
fa-file-text-o fa-genderless
1236
fa-get-pocket fa-hdd-o
fa-gg fa-header
fa-gg-circle fa-headphones
fa-gift fa-heart
fa-git fa-heart-o
fa-git-square fa-heartbeat
fa-github fa-history
fa-github-alt fa-home
fa-github-square fa-hospital-o
fa-gittip fa-hotel
fa-glass fa-hourglass
fa-globe fa-hourglass-1
fa-google fa-hourglass-2
fa-google-plus fa-hourglass-3
fa-google-plus-square fa-hourglass-end
fa-google-wallet fa-hourglass-half
fa-graduation-cap fa-hourglass-o
fa-gratipay fa-hourglass-start
fa-group fa-houzz
fa-h-square fa-html5
fa-hacker-news fa-i-cursor
fa-hand-grab-o fa-ils
fa-hand-lizard-o fa-image
fa-hand-o-down fa-inbox
fa-hand-o-left fa-indent
fa-hand-o-right fa-industry
fa-hand-o-up fa-info
fa-hand-paper-o fa-info-circle
fa-hand-peace-o fa-inr
fa-hand-pointer-o fa-instagram
fa-hand-rock-o fa-institution
fa-hand-scissors-o fa-internet-explorer
fa-hand-spock-o fa-intersex
fa-hand-stop-o fa-ioxhost
fa-hashtag fa-italic
1237
fa-joomla fa-long-arrow-up
fa-jpy fa-magic
fa-jsfiddle fa-magnet
fa-key fa-mail-forward
fa-keyboard-o fa-mail-reply
fa-krw fa-mail-reply-all
fa-language fa-male
fa-laptop fa-map
fa-lastfm fa-map-marker
fa-lastfm-square fa-map-o
fa-leaf fa-map-pin
fa-leanpub fa-map-signs
fa-legal fa-mars
fa-lemon-o fa-mars-double
fa-level-down fa-mars-stroke
fa-level-up fa-mars-stroke-h
fa-life-bouy fa-mars-stroke-v
fa-life-buoy fa-maxcdn
fa-life-ring fa-meanpath
fa-life-saver fa-medium
fa-lightbulb-o fa-medkit
fa-line-chart fa-meh-o
fa-link fa-mercury
fa-linkedin fa-microphone
fa-linkedin-square fa-microphone-slash
fa-linux fa-minus
fa-list fa-minus-circle
fa-list-alt fa-minus-square
fa-list-ol fa-minus-square-o
fa-list-ul fa-mixcloud
fa-location-arrow fa-mobile
fa-lock fa-mobile-phone
fa-long-arrow-down fa-modx
fa-long-arrow-left fa-money
fa-long-arrow-right fa-moon-o
1238
fa-mortar-board fa-picture-o
fa-motorcycle fa-pie-chart
fa-mouse-pointer fa-pied-piper
fa-music fa-pied-piper-alt
fa-navicon fa-pinterest
fa-neuter fa-pinterest-p
fa-newspaper-o fa-pinterest-square
fa-object-group fa-plane
fa-object-ungroup fa-play
fa-odnoklassniki fa-play-circle
fa-odnoklassniki-square fa-play-circle-o
fa-opencart fa-plug
fa-openid fa-plus
fa-opera fa-plus-circle
fa-optin-monster fa-plus-square
fa-outdent fa-plus-square-o
fa-pagelines fa-power-off
fa-paint-brush fa-print
fa-paper-plane fa-product-hunt
fa-paper-plane-o fa-puzzle-piece
fa-paperclip fa-qq
fa-paragraph fa-qrcode
fa-paste fa-question
fa-pause fa-question-circle
fa-pause-circle fa-quote-left
fa-pause-circle-o fa-quote-right
fa-paw fa-ra
fa-paypal fa-random
fa-pencil fa-rebel
fa-pencil-square fa-recycle
fa-pencil-square-o fa-reddit
fa-percent fa-reddit-alien
fa-phone fa-reddit-square
fa-phone-square fa-refresh
fa-photo fa-registered
1239
fa-remove fa-sheqel
fa-renren fa-shield
fa-reorder fa-ship
fa-repeat fa-shirtsinbulk
fa-reply fa-shopping-bag
fa-reply-all fa-shopping-basket
fa-retweet fa-shopping-cart
fa-rmb fa-sign-in
fa-road fa-sign-out
fa-rocket fa-signal
fa-rotate-left fa-simplybuilt
fa-rotate-right fa-sitemap
fa-rouble fa-skyatlas
fa-rss fa-skype
fa-rss-square fa-slack
fa-rub fa-sliders
fa-ruble fa-slideshare
fa-rupee fa-smile-o
fa-safari fa-soccer-ball-o
fa-save fa-sort
fa-scissors fa-sort-alpha-asc
fa-scribd fa-sort-alpha-desc
fa-search fa-sort-amount-asc
fa-search-minus fa-sort-amount-desc
fa-search-plus fa-sort-asc
fa-sellsy fa-sort-desc
fa-send fa-sort-down
fa-send-o fa-sort-numeric-asc
fa-server fa-sort-numeric-desc
fa-share fa-sort-up
fa-share-alt fa-soundcloud
fa-share-alt-square fa-space-shuttle
fa-share-square fa-spinner
fa-share-square-o fa-spoon
fa-shekel fa-spotify
1240
fa-square fa-tasks
fa-square-o fa-taxi
fa-stack-exchange fa-television
fa-stack-overflow fa-tencent-weibo
fa-star fa-terminal
fa-star-half fa-text-height
fa-star-half-empty fa-text-width
fa-star-half-full fa-th
fa-star-half-o fa-th-large
fa-star-o fa-th-list
fa-steam fa-thumb-tack
fa-steam-square fa-thumbs-down
fa-step-backward fa-thumbs-o-down
fa-step-forward fa-thumbs-o-up
fa-stethoscope fa-thumbs-up
fa-sticky-note fa-ticket
fa-sticky-note-o fa-times
fa-stop fa-times-circle
fa-stop-circle fa-times-circle-o
fa-stop-circle-o fa-tint
fa-street-view fa-toggle-down
fa-strikethrough fa-toggle-left
fa-stumbleupon fa-toggle-off
fa-stumbleupon-circle fa-toggle-on
fa-subscript fa-toggle-right
fa-subway fa-toggle-up
fa-suitcase fa-trademark
fa-sun-o fa-train
fa-superscript fa-transgender
fa-support fa-transgender-alt
fa-table fa-trash
fa-tablet fa-trash-o
fa-tachometer fa-tree
fa-tag fa-trello
fa-tags fa-tripadvisor
1241
fa-trophy fa-vine
fa-truck fa-vk
fa-try fa-volume-down
fa-tty fa-volume-off
fa-tumblr fa-volume-up
fa-tumblr-square fa-warning
fa-turkish-lira fa-wechat
fa-tv fa-weibo
fa-twitch fa-weixin
fa-twitter fa-whatsapp
fa-twitter-square fa-wheelchair
fa-umbrella fa-wifi
fa-underline fa-wikipedia-w
fa-undo fa-windows
fa-university fa-won
fa-unlink fa-wordpress
fa-unlock fa-wrench
fa-unlock-alt fa-xing
fa-unsorted fa-xing-square
fa-upload fa-y-combinator
fa-usb fa-y-combinator-square
fa-usd fa-yahoo
fa-user fa-yc
fa-user-md fa-yc-square
fa-user-plus fa-yelp
fa-user-secret fa-yen
fa-user-times fa-youtube
fa-users fa-youtube-play
fa-venus fa-youtube-square
fa-venus-double
fa-venus-mars
fa-viacoin
fa-video-camera
fa-vimeo
fa-vimeo-square
1242
<!DOCTYPE html>
<html>
<head>
<!-- To use the Font Awesome icons, we add the following line inside the
<head> section of our HTML Document -->
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head> The icon sizes can be increased in proportion to their container using
<body> the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes.
♥
<i class="fa fa-heart fa-4x"></i>
</body>
♥♥ ♥♥
</html>
1243
<!DOCTYPE html>
<html>
JavaScript program to print the contents of the current window
<body>
</body>
</html>
<script>
Heron's formula states that the area of a triangle whose sides
let a = 7; have lengths a, b, and c is √s(s − a)(s − b)(s − c) where s is the
let b = 5; a+b+c
semiperimeter of the triangle; that is, s =
2
let c = 9;
let s = (a + b + c)/2;
document.write(Math.sqrt(s*((s-a)*(s-b)*(s-c))));
// Output: 17.41228014936585
JavaScript program to find the area of a triangle where
</script>
lengths of the three of its sides are 7, 5, 9
<script>
document.write(document.URL);
</script> <script>
</script>
1244
Write a JavaScript program to calculate the sum of the two given numbers. If the two
numbers are equal, then return 2 times their sum.
Solution:
<script>
let x = 10;
let y = 10;
if (x == y) {
console.log(2 * (x + y));
# Output:
}
40
else {
console.log(x + y);
</script>
<script>
let x = 10;
let y = 20;
if (x == y) {
console.log(x + y);
</script>
1245
<script>
JavaScript program to check 2 given numbers and return true if
let y = 45;
// Output: true
</script>
<script>
let x = 100;
console.log((x % 5 == 0 || x % 10 == 0));
<script>
console.log("ecdafb".split("").sort().join(""));
// Output: abcdef
JavaScript program to sort the letters of
</script> a given string in alphabetical order
<script>
</script>
1246
<script>
x=23; 23 → 2 + 3 → 5
<script>
function myfunc() {
console.log("Albert");
JavaScript program to measure the time
} taken by a function "myfunc()" to execute
var x = Date.now();
myfunc();
var y = Date.now();
</script>
# Output:
Albert
Albert
1247
<script>
console.log(/^[a-z][a-z0-9+.-]*:/.test('https://google.com'));
// Output: true
console.log(/^[a-z][a-z0-9+.-]*:/.test('/temp/files'));
// Output: false
JavaScript program that will return true if the given string
<script>
const distance = (a0, b0, a1, b1) => Math.hypot(a1 - a0, b1 - b0);
console.log(distance(2, 3, 4, 2));
JavaScript program to calculate the
// Output: 2.23606797749979 Euclidean distance between two points
</script>
<script>
let sum = 0;
if (i % 2 == 0 && i % 4 == 0) {
sum = sum + i;
}
JavaScript program to sum the
} multiples of 2 and 4 under 20
console.log(sum);
// Output: 40
</script>
1248
<script>
<?php
phpinfo();
?>
<?php
echo basename($_SERVER['PHP_SELF']);
?>
<?php
if (!empty($_SERVER['HTTPS'])) {
}
<?php
else {
# Redirect a user to "https://www.wikipedia.org/"
echo 'HTTP enabled';
header('Location: https://www.wikipedia.org/');
}
?> ?>
1249
Number of clusters
Number of nearest neighbors
Locating substances capable of keeping a quantum state for prolonged enough to allow for computations
Constructing a quantum computational model that can be expanded to carry out exceedingly challenging
calculations.
Constructing methodologies that can utilize the quantum state to carry out computations more quickly
than traditional techniques
A technique for forecasting future outcomes using data from the past. It
Illustrates how data evolves over time Figure out which way the data is changing
1250
Data collection + Data cleaning → Data Engineer
Statistical Interaction:
PYTHON is used for data cleaning because it has modules like NumPy and
Progressive rendering:
An idea that suggests presenting the most important stuff to the browser first and the
less important pieces afterwards, as needed by the user
HTTP ETag:
1251
<script>
<script>
function myfunc() {
var myfunc=function() {
console.log("Albert Einstein");
console.log("Albert Einstein");
}
}
myfunc();
myfunc();
</script>
</script>
<script>
myfunc();
function myfunc() {
</script>
<script>
} }
} myfunc(210);
// Output: 15 </script>
</script>
1252
<script>
We use the "return keyword" to return a
console.log(myfunc(14, 13)); value, the function execution is stopped as
soon as the return statement is invoked
function myfunc(x, y) {
return x + y;
}
# Output: 27
</script>
<script> <script>
</script> </script>
1253
<script>
console.log(typeof 25);
// Output: number
// Output: string
typeof 25 will return "number" and typeof
</script> "number" will return string
<script>
const myfunc=()=> {
console.log("Albert Einstein");
myfunc();
</script>
Memorization:
Constructor functions
1254
<script>
console.log([...names, ...age]);
</script>
Utilising a variety of techniques and strategies to create models that best match the data
1255
<?php
$x = '6';
$y = &$x;
# Output: 26, 26
$y = "2$y";
?>
<script>
function mult(x, y, z) {
return x * y * z;
console.log(mult(...[1, 2, 3]));
// Output: 6
// 1 × 2 × 3 = 6
</script>
<script>
</script>
1256
<style>
body * {
margin: 30px;
?
border: 2px solid orange;
</style>
</div>
</div>
</div>
<script>
</script>
<script>
</noscript>
1257
<?php
$x = "Albert";
$y = "Einstein"; Output:
echo $x." ". $y; Albert Einstein
?>
<?php
for($i=1;$i<=5;$i++) {
Output:
for($j=1;$j<=$i;$j++) {
*
echo "*";
**
} ***
****
echo "\n";
*****
?>
1258
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: yellow;
</style>
</head>
<body>
</body>
</html>
1259
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: yellow;
width: 200px;
height: 65px;
Output:
border: 1px solid;
</style>
</head>
<body>
</body>
</html>
1260
<!DOCTYPE html>
The use of "calc()" function to calculate the width
<html> and height of a <p> element
<head>
<style>
#mytxt {
#mytxt {
width: calc(400px - 200px);
width: 200px;
height: calc(100px - 35px);
height: 65px;
border: 1px solid black;
border: 1px solid black;
background-color: yellow;
background-color: yellow;
}
}
</style>
</head>
<body>
</body>
</html>
Output:
1261
<?php
echo chr($i);
# Output: ABCDEFGHIJKLMNOPQRSTUVWXYZ
?>
<!DOCTYPE html>
<html>
<head>
.mytxt {
column-count: 3;
column-gap: 50px;
50 pixels gap between the columns
}
</style>
</head>
<body>
</div>
</body>
</html>
1262
# Output:
<!DOCTYPE html>
column-gap: 50px;
column-rule-style: solid;
column-rule-width: 5px;
column-rule-color: green;
</style>
</head>
<body>
</div>
</body>
</html>
1263
# Output:
are successful in creating prediction models that work well on new cases
Predictive models that are combined into an ensemble make up for one
Torch:
1264
How a data scientist operates?
Information regarding:
What is typical?
What can we predict?
What is the standard?
How likely is that?
that is conceivable. Machine learning is built on neural networks. One of the most
important scientific achievements in Modern history is the neural network. Problems that
Face Recognition
Speech Recognition
1265
TensorFlow.js
A well-known JavaScript library for machine learning is Tensorflow. We can train and
use machine learning in the web browser due to Tensorflow. We can incorporate
<!DOCTYPE html>
<html>
<head>
<!-- To use TensorFlow.js, we add the following script tag to our HTML Document -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
</head>
<body>
<script>
const z= x.add(y);
1266
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
</head>
Microservices architecture is a group of smaller,
<body>
independently deployable services as compared to a monolithic
<!-- Tensor Subtraction --> application, which is constructed as a single integrated unit.
<script>
const z= x.sub(y);
1267
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
on creating applications
<script>
const z= x.mul(y);
</script>
</body>
</html>
1268
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
</head>
<body>
<script>
const z= x.div(y);
Speaking
</body>
Reasoning
</html> Studying
Designing
Knowing
1269
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
</head>
<body>
<script>
const z= x.square();
</script>
</body>
Brain.js
</html>
1270
The collection of information makes up to 80% of a ML project
Intelligent but imprecise and slow Foolish but precise and fast
Client-Server Model:
Designed for applications that require a lot of Designed for applications that require a lot of
computing power, like some scientific simulations storage power, like running Spark or Hadoop or
or high-performance web servers doing real-time big data analytics
1271
Dynamic scaling: The ability to automatically change capacity depending on load or
other metrics
Predictive scaling: The ability of changing capacity in response to anticipated demand
Load Allocation:
The service that distributes incoming traffic among the resources that is accessible.
It will divide up the resources according to their availability.
and microservices
1272
Did you know?
poet Lord Byron, created the first computer program in human history.
FORTRAN for IBM in 1954. It was made available for purchase in 1957. Even
1273
30 Bash Scripts for Beginners
: '
calculate the
Multiline comment
square value of the number: 4.
'
((y=4*4))
echo $y
# Output: 16
1274
x=true
i=0
while [ $x ]
do Output:
echo $i 0
if [ $i -eq 4 ]; 1
then 2
break 3
fi
4
((i++))
done
done
done
printf "\n"
printf "\n"
# Output: 0 1 2 3 4
# Output: 5 4 3 2 1
2
done
3
printf "\n"
4
1275
echo "Please enter your name:"
read x
# Output:
i=5
i=5
if [ $i -lt 10 ];
if [ $i -gt 10 ];
then
then
echo "i is less than 10"
echo "i is less than 10"
else
else
echo "i is greater than 10"
echo "i is greater than 10"
fi
fi
# Output: i is less than 10
# Output: i is greater than 10
read x Output:
echo "Enter password:"
Enter username:
read y
manju # entered username
if [[ ( $x == "manju" && $y == "123" ) ]]; then
Enter password:
echo "user authentication passed"
123 # entered password
else
fi
1276
echo "Please enter a number:"
read i
fi
read i
if [ $i -eq 2 ];
then
Output:
echo "You earned the first prize"
Please enter a number:
elif [ $i -eq 4 ];
echo "You earned the second prize" You earned the first prize
elif [ $i -eq 8 ];
then
else
fi
1277
echo "Please enter a number:"
read i
case $i in
2)
Output:
echo "You earned the first prize" ;;
Please enter a number:
4)
*)
esac
if [ "$x" == "$y" ]
then
echo "Both strings are not equal" Please enter a string: john # entered string
1278
read -p "Please enter a string: " x
if [ "$x" != "$y" ]
Output:
then
Please enter a string: john # entered string
echo "Both strings are not equal"
Please enter a string: alan # entered string
else
Both strings are not equal
echo "Both strings are equal"
fi
a="Albert "
b=" Einstein"
Output:
echo "$a$b"
Albert Einstein
c=$a+$b
Albert + Einstein
c+=
echo $c
i=${x:7:6}
echo $i
# Output: Python
1279
echo "Please enter a number:"
read x
Output:
echo "Please enter a number:"
Please enter a number:
read y
3 # entered number
((z=x*y)) Please enter a number:
function AL()
AL
x() {
area=$(($1 * $2))
x 60 10
1280
x() {
volume=$(($1 * $2 * $3))
echo "Volume of a rectangle of length $1, breadth $2 and height $3 is: $volume"
x 12 16 18
# Output: Volume of a rectangle of length 12, breadth 16 and height 18 is: 3456
x=0
0
do
1
echo "$x"
2
let x++
3
done 4
while true
do
done
1281
function x() {
a="Howdy, $name"
echo $a
} Output:
i=$(x)
Howdy, manju
echo "$i"
read x
`mkdir $x`
# Output:
Output:
for names in Sham Mary John James Lawrence
Sham
do
Mary
James
done
Lawrence
1282
echo "Enter the name of the directory:"
read x
if [ -d "$x" ] Output:
fi
for i in *
do
Read all files from
ls -l $i the current directory
done
x='1.txt'
done < $x
1283
echo "Enter the name of the file to remove:"
read x
rm -i $x
# Output:
echo ${x[@]}
echo ${!x[@]}
# Output:
0 1 2 3 4
1284
for PID in $$
do
Prints PID of the
echo $PID current shell
done
id=10
1.sh
x="Albert"
source 1.sh
# Output:
Welcome Albert
Your id is 10
myfunc(){
echo $1 $2 $3 $4
1285
Year=`date +%Y`
Month=`date +%m`
Day=`date +%d`
Hour=`date +%H`
Minute=`date +%M`
Second=`date +%S`
echo "Current Date is: $Day-$Month-$Year" # Output: Current Date is: 29-06-2022
echo "Current Time is: $Hour:$Minute:$Second" # Output: Current Time is: 17:53:06
if [ $? -eq 0 ]; then
else
fi
do -4
-3
echo "$x"
-2
done
-1
1286
for i in {1..10}; do echo -n "$i"; done
# Output: 12345678910
x="manju"
then
Check whether or not the
echo "Hey! string found"
file '/etc/passwd' contains
else the string 'manju'
fi
read x
if [ $x -gt 0 ]
then
Output:
echo "Positive number"
Please enter a number:
else
fi
1287
x=(1 2 3 4 5)
sum=0
printf 'Albert'
for a in ${x[@]}
printf '%s\n' 'Einstein'
do
done # Output:
# 1 + 2 + 3 + 4 + 5 = 15
x="Alan+Mathison+Turing"
i=1
for i in "${a[@]}"
do
do
echo 'Albert'
echo $i
((i++))
done
done
# Output:
# Output:
Alan Albert
Mathison
Albert
Turing
Albert
Albert
1288
30 Python Scripts for Beginners
import itertools
# ASCII value of C is 67
# ASCII value of D is 68
print({ord('C'): ord('D')})
# ASCII value of A is 65
# ASCII value of B is 66
# ASCII value of C is 67
# ASCII value of D is 68
print(eval('"DDD".count("D")')) # Output: 3
1289
i= 2
import numpy as np
a = 'Alan Turing'
import io
x = io.StringIO(a)
a = 'Alan Turing'
import io
x = io.StringIO(a)
a = 'Alan Turing'
import io
x = io.StringIO(a)
print(x.seek(15)) # Output: 15
1290
import sys
for x in range(3):
for x in range(3):
print('Albert')
sys.stdout.write('Albert\n')
Albert
sys.stderr.write('Albert\n')
Albert
a = 0 B
C
for a in range(0, len(x)):
D
print(x[a])
E
1291
x = ['A', 'B', 'C','D', 'E']
Output:
a = 0
C
for a in range(2, len(x)):
D
print(x[a]) E
x.add('D')
x.add('F')
import sys
print(sys.version_info)
print(sys.version)
# Output:
1292
print('bunny' == 'bunny') # Output: True
x = 'price'
y = 12.568
book = [
p = 861.45891
q = 861.45891
1293
x = 1905
y = 'Papers'
x = 1925
y = 'Dollars'
x = 6
y = 4
y = [len(i) for i in x]
Hi
print('Hi')
Hi
else:
Hi
print('Albert') Albert
1294
for x in range(3):
print('Hi')
Output:
if x == 1:
Hi
break
Hi
else:
print('Albert')
for a in []:
while False:
print('Hi')
print('Hi')
else: else:
print('Albert') print('Albert')
# Output: Albert
x = iter(range(2, 4))
a, b = x
x = {}
y = 'Alan'
Output:
z = []
{'Alan': []}
x.setdefault(y, z)
{'Alan': ['Turing']}
print(x)
z.append('Turing')
print(x)
1295
p = float(input("Enter the marks obtained in Practical: "))
else:
# Output:
# hello.py
print("Hello World!")
import os
p = "Alan\n"
Output:
q = "Turing"
Alan
print(p + q)
Turing
1296
from time import sleep
i('Einstein')
x = 4
n = 3
# Method 1:
b = x ** n
# Method 2:
b = pow(x,n)
# Method 3:
import math
b = math.pow(x,n)
1297
# import getpass module
import getpass
if x == "alan@123":
print("Authentication passed")
else:
print("Authentication failed")
# Output:
Authentication failed
a = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
import itertools
print(list(itertools.repeat('Alan', 4)))
1298
import itertools
x = itertools.cycle([4, 5])
# Output: [4, 5, 4, 5]
import itertools
a, b = itertools.tee(['Alan', 'Turing'], 2)
print(list(a))
Output:
print(list(b))
['Alan', 'Turing']
['Alan', 'Turing']
import itertools
import itertools
1299
# Python program to list files in a directory
import os
x = os.listdir('C:/Users/Manju')
for i in x:
print(i)
import itertools
# Output: [(2, 2), (2, 4), (2, 6), (4, 4), (4, 6), (6, 6)]
# Output: [(2, 4), (2, 6), (4, 2), (4, 6), (6, 2), (6, 4)]
1300
# Define the string
i = 'Albert'
a, b, *c = range(4)
a, b, *c = range(2)
print(a, b, c) # Output: 0 1 []
a, *b, c, d = range(6)
*a, b, c, d = range(6)
x = list(range(10))
print(x)
# Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(x)
1301
x = list(range(10))
print(x)
# Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(x)
x = list(range(10))
print(x)
# Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
del x[4:6]
print(x)
# Output: [0, 1, 2, 3, 6, 7, 8, 9]
print([['#'] * 2] * 2)
x= ['#'] * 2
Output:
y = []
for i in range(2): [['#', '#']]
y.append(x)
[['#', '#'], ['#', '#']]
print(y)
1302
x = ['A', 'ABC', 'AB', 'ABCD']
print(sorted(x))
print(sorted(x, key=len))
print(deque(range(5), maxlen=5))
print(sorted(x, key=int))
print(sorted(x, key=str))
1303
print(frozenset(range(5))) # Output: frozenset({0, 1, 2, 3, 4})
# Output:
{'l', 'y', 'i', '|', '}', 'r', 'g', 'h', '{', 'u', 't', 'p',
'n', 'w', 'q', 'x', 'o', 'j', 'm', 'd', 'f', 'e', 's', 'v', 'z', 'k'}
import PyPDF2
i = open('1.pdf', 'rb')
x = PyPDF2.PdfFileReader(i)
i.close()
import os
print(os.listdir(b'.'))
print(os.listdir(b'.'))
1304
# python program to open an image
# Output:
1.png
1305
from operator import add
import math
y = list(x)
x = {'Name': 'Albert', 'Died': 1955}
y['born'] = 1979
return x y = tuple(x)
1306
The insulation of data from direct access
Data security
Data hiding
After providing proper username and password only, we can access our Account information.
Abstraction
Deals with hiding the complexity of a program Deals with the security of data in a program
Focuses on wrapping the complex data in order Focuses on restricting the use of data − intending to
to present a simpler view for the user assure the data security.
private protected
Accessible from own class ✓ ✓
Accessible from derived class × ✓
Advantages of abstraction:
Reduces Complexity
Avoid Code Duplication
1307
Eases the burden of maintenance
Increase Security and confidentiality
2 classes: A and B
Multi-level inheritance:
3 classes: A, B and C
Multiple Inheritance:
3 classes: A, B and C
Hierarchical Inheritance:
3 classes: A, B and C
Hybrid Inheritance:
4 classes: A, B, C and D
1308
Inheritance → reusability
Encapsulation → security
class Dog{
public void bark(){
System.out.println("woof ");
}
Same method name
}
class Hound extends Dog{ Same parameter
public void sniff(){
System.out.println("sniff ");
}
1309
class Dog{
Same method name
public void bark(){
Different parameter
System.out.println("woof ");
}
Constructor Method
A Constructor's basic function is to create an instance A Method's basic function is to execute java code
of a class
Have no return type Have any valid return type or no return type
Have the same name as their class Have the name other than the class name
Constructors will start with a uppercase letter Methods will start with a lowercase letter
1310
DevOps isn't any single person's job. It's everyone's job.
Christophe Capel
Plan
Workflow
Security and
Collaboration Application Compliance
Operate Develop
Continuous
improvement
Deliver
1311
Development (Software engineering) + Quality assurance + operations = DevOps
DevSecOps
Communication
Collaboration
Dev Integration Ops
Sec
1312
Commit source Continuous build
Developer Git Jenkins
Continuous delivery
Deployment
Docker
DevOps Flow
DevOps Tools
1313
DevOps
Agile
Development start Development end Release Production support
Development Operations
Testing
Cloud Service:
Applications Applications
Data Data
You
Runtime Runtime
manage
Middleware Middleware
You manage OS OS
Virtualization Virtualization
Networking Networking
Applications
Applications
You manage Data
Data
Runtime
Runtime
Middleware
Middleware
Others
OS
OS manage
Others Virtualization
Virtualization
manage
Servers
Servers
Storage
Storage
Networking
Networking
1314
Application Release Management
Craft an experiment
1315
# Basic Hello World program written in Groovy
class MyClass {
static void main(String[] args) {
println('Hello World');
}
}
Command:
ifstat
Description:
1316
Processes
Processes that create other processes Processes that are created by other
during runtime processes during run-time
Command:
pidof bash
Description:
echo $$
echo $PPID
1317
Command:
Description:
Service for hosting and distributing docker images Collection of related Docker images
1318
Selenium supports 2 types of testing:
Regression Testing → retesting a product around an area where a bug was fixed.
Command:
ps au
ps axu
Description:
Command:
ps aux
Description:
Build Docker Commit Docker Push Docker Pull Docker Run Docker
Image Image Image Image container
1319
# Takes in integer x and returns the binary representation of x in a string format
x = 15
print(bin(x))
0b1111
x = 10
print(oct(x))
0o12
x = 100
print(hex(x))
0x64
x="python\nlanguage"
print(x)
python
language
1320
x="python\tlanguage"
print(x)
python language
sequence
the sequence
list_1=[1,2,3,4,5]
list_2=[6,7,8,9]
if item in list_2:
print("overlapping")
else:
print("not overlapping")
not overlapping
1321
x = 24
y = 20
if ( x not in list ):
else:
if ( y in list ):
else:
Database layer
Applications
Native
1-tier 3-tier
Web
2-tier N-tier
Hybrid
1322
Java Design Patterns:
Creational design patterns → Design patterns that deal with the way of creating objects.
Structural design patterns → Design patterns that deal with how classes and objects can be composed to
form larger structures.
Behavioral design patterns → Design patterns that deal with algorithms and the assignment of responsibilities
between objects.
JEE Design Patterns → Design patterns that deal with providing solutions to the Java EE-based software
applications and frameworks.
Robotic Process Automation → Reduces the number of people and automate task just like a human being
1323
Robotic Process Automation:
Software-as-a-Service (SaaS)
3 Components of Cloud Computing:
Infrastructure-as-a-Service (IaaS)
Platform-as-a-Service (PaaS)
Label Encoding: A method for transforming labels of categorical data into numeric form so they may
be processed by a machine learning model
Eager Learning: Putting more effort into training and less effort into prediction
Lazy Learning: Putting more effort into prediction and less effort into training
1324
Data Mining Statistics
Simple regression model:
Methodology Inductive Deductive In this regression model, a single, univariate data
feature is used to derive the predictions
Variables Large Small
Image Classification
Unsupervised Learning
Dimensionality reduction
Text Mining
Types
Face Recognition
Applications
Big Data Visualization
Biology
1325
Gaming
Finance Sector
Manufacturing
Applications of Reinforcement Learning Inventory
Management
Keras Tensorflow
A simple Python library for Deep Learning A set of libraries for Machine Learning
1326
The main phases of risk analysis are: Identification of Risk
Analyzing the Risk
Evaluating the Risk
The process of identifying, analyzing, evaluating and Treat the Risk
treating the risks that could cause the failure of the project Review the Risk
Differential privacy
Step 1: Define the Problem
𝐭𝐫𝐚𝐧𝐬𝐟𝐨𝐫𝐦𝐞𝐝 𝐢𝐧𝐭𝐨
Data preprocessing (Unstructured raw data → Structured useful and efficient data)
Model building
Quantum Computer: A machine that harnesses
Model training and evaluation the properties of quantum mechanics to store data
and perform computations
1327
Data fusion
9 Interesting Python Facts
In python we can return multiple values:
def XYZ():
p = 3 The process of combing information
q = 2
return p, q from numerous data sources to produce
a, b = XYZ() more appropriate, authentic and useful
print(a, b)
information than that provided by any
3 2
repository
orange
681
1328
a = 3
b = 2
Polymorphic malware
print('Before Swapping')
print(a, b)
a, b = b, a
print('After Swapping')
print(a, b)
3 2
After Swapping
2 3
My Python version Number: 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
AI Transparency
Output on the screen:
Understanding, explaining and
1
interpreting how AI systems
2
make decisions and use data
3
681
1329
We can convert nested list into one list:
Risk-based testing: A method of
import itertools
x = [[1, 2], [3, 4], [5, 6]] software testing that is based on the process
print(list(itertools.chain.from_iterable(x)))
of analyzing the risks associated with the
[1, 2, 3, 4, 5, 6]
681
1330
C++ Exercises
Intra-personal intelligence: The ability to interpret and recognize our feelings and emotions
Interpersonal intelligence: The ability to interpret and recognize other people's feelings and emotions
Question 1
Solution:
#include<iostream>
int main() Heuristic Knowledge: Practice knowledge,
{ precise reasoning, and one's capability to
std::cout<<"Hello World!"; analyze and guess
return 0;
}
Solution:
#include<iostream>
using namespace std; Phonology: The study of sound
int main()
patterns found in languages
{
cout<<"Hello World!";
return 0;
}
1331
Question 2
Question:
Solution:
#include<iostream>
using namespace std;
int main() Data Stack: A bunch of technologies and
{
services that an enterprise organization use to
float r, area;
store, manage and access information
cout<<"Enter any number:";
cin>>r;
area = 3.14 * r * r;
cout<<"The area of the circle = "<< area;
return 0;
}
Solution:
1332
#include<iostream>
using namespace std;
int main() May or may not happen evenly
{
float a, b, sum; Not probable to happen Probable to happen
cout<<"Enter any two numbers:"; P(E) = 0 P(E) = 1
cin>>a; Cannot happen P(E) = 0.5 Certain to happen
cin>>b;
sum = a+ b;
cout<<"The sum of a and b = "<< sum;
return 0;
}
Question 4
Question:
Solution: Forecasts
Real world Probability theory
#include<iostream> (The branch of
using namespace std; mathematics concerned
Data with the possibility of the
int main()
occurrence of events)
{
int a, b;
a=2; Rules of
b = a * a; inference
cout<<"The square of a = "<< b; Modeling
return 0;
}
1333
Question 5
Question:
Solution:
#include<iostream>
using namespace std; Code coverage: Number of lines of source code that is actually tested
int main()
Number of lines of source code that is actually tested
Code Coverage % = × 100
{ Total number of lines of source code
int a, b;
a = 2;
b = 3; Helps in
if(a>b) Increasing the quality of source code
tested while test coverage is a measure of how well the software application
1334
Question 6
Question:
Solution:
Number of lines of source code increases
#include<iostream>
using namespace std; Code length increases
int main()
{
Execution time increases
int i, avg, sum = 0;
int num [5] = {16, 18, 20, 25, 36};
Code performance decreases
for(i=0; i<5; i++)
sum = sum + num [i];
avg = sum/5;
cout<<"Sum of the Elements in the array = "<< sum <<endl;
cout<<"Average of the elements in the array= "<< avg<<endl;
return 0;
}
Question 7
Question:
Write a program such that a Switch (case) allows to make a decision from the
number of choices, i.e., from the number of cases.
1335
Solution: Extreme Programming
#include<iostream>
using namespace std;
int main() Software development methodology
{
specifically designed to improve software
char ch;
quality and increase customer satisfaction by
cout<<"Enter any character:";
cin>>ch; allowing development team to respond to
switch(ch)
changing customer requirements
{
case 'R':
cout<<"Red";
break;
case 'W':
Fail Fast Philosophy
cout<<"White";
break;
case 'Y':
cout<<"Yellow"; If it is possible to learn from failure then the quickly
break; the failure occurs, the quickly the learning begins
case 'G':
cout<<"Green";
break;
default:
cout<<"Error"; Vertical scaling Horizontal scaling
break;
Increasing instance size Adding more instances
}
return 0;
}
Degauss:
1336
Question 8
Question:
Solution:
Design Thinking
#include<iostream>
(A human-centered approach to innovation)
using namespace std;
int main()
{
int x, y, *p, *q;
cout<<"Enter any integer:";
cin>> x;
A problem-solving approach that places a user at
cout<<"Enter any integer:"; the center of the product design
cin>> y;
p = &x;
q = &y;
5 Stages of Design Thinking:
if(*p>*q)
{ Learn: who are my customers?
cout<<"x is greater than y";
Define: what are the needs of the customers?
}
else Create new ideas
{
Build a representation: How can I display my ideas?
cout<<"y is greater than x";
} Test: What worked and what did not?
return 0;
}
1337
Question 9
Question:
Solution:
Question 10
Question:
Write a program to print the first 10 numbers starting from one together with
their squares and cubes.
1338
Solution: Linting
(Pre-code review)
#include<iostream>
using namespace std;
int main()
The automated checking of application source code for
{
programmatic and dramatic errors
int i;
for( i=1; i<=10; i++)
cout<<"number = "<< i <<" its square = "<< i*i <<" its cube = "<< i*i*i<< endl;
return 0;
}
Question 11
Question:
File locking: A mechanism that restricts access to a file
Write a program:
Minimal Viable Product: A product with minimum basic
If you enter a character M features which is introduced in the market just to get the
Output must be: ch = M. attention of the consumers
Solution:
Product backlog
#include<iostream>
using namespace std;
int main()
A prioritized list of tasks that need to be finished during
{
char M;
the development of new product or while upgrading
1339
return 0;
}
Question 12
Question:
Value Proposition
A promise of value specified by a company that answers why customers should choose their
products or services
1340
Question 13
Question:
Solution: Blogosphere
#include<iostream>
using namespace std;
int main() All of the blogs or bloggers on the internet
{
int i, product = 1;
for( i=1; i<=10; i++)
product = product * i;
cout<<"The product of the first 10 digits = " << product;
return 0;
}
RSS
Question 14
(Rich Site Summary)
1341
#include<iostream>
using namespace std;
Bits-Per-Second
int main()
{
int a; A measure of the rate at which data is sent
a = -35; from one location to another
if(a>0)
{
cout<<"Number is positive";
}
CDMA
else
(Code Division Multiple Access)
{
cout<<"Number is negative";
}
return 0; A wireless data and voice communication protocol
}
Question 15
Question:
Solution:
#include<iostream>
using namespace std;
int main() Cyberspace: The entire set of information resources
{ accessible via computer networks
int x, y;
cout<<"Enter any number:";
1342
cin>>x;
cout<<"Enter any number:";
cin>>y; Imputation: The process of filling in
if(x-y==0)
missing data values in a dataset
{
cout<<"The two numbers are equivalent"; Devalue the performance of data
else
{
cout<<"The two numbers are not equivalent";
}
return 0;
}
Question 16
Question:
Solution:
#include<iostream>
using namespace std;
int main()
{ Data-directed decision making: The
int a, b, c; process of using data to support making
cout<<"Enter any number:"; crucial business decisions
cin>>a;
cout<<"Enter any number:";
cin>>b;
1343
c = a % b;
cout<<"The remainder of a and b = "<< c;
return 0;
}
Question 17
Question:
Solution:
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"Enter any number:";
cin>>a; Descriptive statistics Inferential statistics
if(a%2 = = 0)
{
cout<<"The number is even";
} Describe the data Generalize the data
else
{
cout<<"The number is odd";
}
return 0;
}
1344
Question 18
Question:
Solution:
#include<iostream>
using namespace std;
int main()
Bounce rate:
{
char a = 'A'; The percentage of visitors to a website who
while (a<='Z') leave without browsing around
{
cout<<" \n"<< a++;
}
return 0;
}
Question 19
Question:
numbers.
1345
Solution:
#include<iostream>
using namespace std;
• 1 Brontobyte = 1027 bytes
int main()
• 1 Yottabyte = 1024 bytes
{
• 1 Exabyte = 1018 bytes
int a, b, c, d, e, f; • 1 Zettabyte = 1021 bytes
a = 10; • 1 Terabyte = 1012 bytes
b=12; • 1 Petabyte = 1015 bytes
c=a+1; • 1 Gigabyte =109 bytes
d=b+1; • 1 Megabyte =106 bytes
e=a-1;
f=b-1;
cout<<"The incremented value of a = "<< c << endl;
cout<<"The incremented value of b = "<< d << endl;
cout<<"The decremented value of a = "<< e << endl;
cout<<"The decremented value of b = "<< f << endl;
return 0;
}
Question 20
Question:
Solution:
#include<iostream>
1346
using namespace std;
int main()
{ Correlation analysis: A method of statistical data analysis
int P,T, R, SI;
that determines whether there is a negative or positive
cout<<"Enter principal amount:";
relationship between variables
cin>>P;
cout<<"Enter time:"; A correlation of + 0.9 indicates a strong positive relationship
cin>>R;
SI = P*T*R/100;
cout<<"the simple interest = "<<SI;
return 0;
}
Question 21
Question:
Solution:
#include<iostream>
using namespace std;
int main() • Failover: Automatic workload transfer from a failed primary server to a backup
{ server
int a, b, c; • Failback: The process of returning back the work load to the primary server after
cin>>a;
cout<<"Enter any number:";
1347
cin>>b;
cout<<"Enter any number:";
cin>>c;
if(a>b&&a>c)
{ Global Positioning System
cout<< a<<" is greater than "<< b<<" and "<<c;
}
Location data: GPS data that describes a specific
else if (b>a&&b>c)
geographical location
{
cout<< b<<" is greater than "<< a <<" and "<<c;
}
else
{
cout<< c<<" is greater than "<< b<<" and "<< a;
}
return 0;
}
Question 22
Question:
Solution:
#include<iostream>
using namespace std; Multi-Dimensional Database: A database designed for data warehousing and online
int main() analytical processing applications that provide a multidimensional view of data
{
int i, n, fact=1 ;
1348
cout<<"Enter any number:";
cin>>n; Object Database: A database system in
for(i=1; i<=n; i++) which data is stored as objects
fact = fact *i;
cout<<"\n Entered number is: "<< n;
cout<<"\n The factorial of the entered number "<< n <<" is: "<< fact;
return 0;
}
Question 23
Question:
Solution:
#include<iostream>
#include<string.h> Optimization analysis
using namespace std;
int main()
{ A method through which an enterprise organization improves the
char ch[4]; efficiency of a process by evaluating the optimization of the process
cin>>ch;
cout<<"The length of the string = "<< strlen(ch);
return 0;
}
1349
Question 24
Question:
Solution:
#include <iostream>
using namespace std; Data Efficient Learning: A kind of machine
int main() learning that is capable of understanding complex
{ challenges to draw logical conclusions without
char c; relying on enormous amounts of data
cout << "Enter a character: ";
cin >> c;
cout << "ASCII Value of " << c << " is " << int(c);
return 0;
}
Question 25
Question:
Write a program to check whether the entered character is a lower case letter or
not.
1350
Solution: Data Analysis
#include<iostream> Collect the Data → Analyze the Data → Visualize and share your findings
using namespace std;
int main()
{
char ch = 'a';
Decorators
if(islower(ch))
cout<<"you have entered the lower case letter";
else
Functions which modify the
cout<<"you have entered the upper case letter";
functionality of other functions
return 0;
}
Question 26
Question:
Write a program to check whether the entered character is a upper case letter or
not.
1351
else
cout<<"you have entered the lower case letter";
return 0;
}
Question 27
Question:
Write a program to convert the lower case letter to upper case letter.
Solution:
#include<iostream>
using namespace std;
Frame language: A technology used for
int main()
{
knowledge representation in AI
char ch = 'a';
char b = toupper(ch);
cout<<" lower case letter "<<ch<<" is converted to upper case letter "<<b;
return 0;
}
1352
Ebert test
Question 28
Question:
Whether a computer-based synthesized voice
Write a program to print the output:
can tell a joke with sufficient skill to make an
Einstein [0] = E
audience laugh
Einstein [1] = I
Einstein [2] = N
Einstein [3] = S
Existential risk
Einstein [4] = T
Einstein [5] = E
AI progress could someday result in human extinction or some other
Einstein [6] = I
irrecoverable global disaster
Einstein [7] = N
Solution:
#include<iostream>
using namespace std; Machine perception: The ability of a machine
int main() to simulate − the way that human beings perceive
{ the world around them
int i;
char name [8] = {'E' , 'I', 'N', 'S', 'T', 'E', 'I', 'N'};
for(i=0; i<8; i++)
cout<<"Einstein ["<< i <<" ] = "<< name[i] << endl;
return 0;
}
1353
Question 29 Error-driven learning
Question:
Write a program to print the output: The difference between the value
using structures.
Solution:
#include<iostream>
using namespace std;
Intelligence Amplification: The effective use of AI
int main()
methods in enhancing human intelligence
{
struct book {
char name;
float price;
int pages; Machine vision
int edition;
};
struct book b1= {'B', 135.00, 300, 8};
The ability of a machine to
cout<<"Name of the book = "<< b1.name<< endl;
cout<<"Price of the book = "<< b1.price<<endl; identify and evaluate images
cout<<"Number of pages = "<< b1.pages<<endl;
cout<<"Edition of the book = "<< b1.edition<< endl;
return 0;
}
1354
Question 30
Question:
Solution:
#include<iostream>
using namespace std;
int square(); Correlation → how strongly two variables are related
1355
Question 31 Protheses: A mechanical device with computer assistance that
substitutes or enhances some basic human functionality
Question:
Solution:
#include<iostream>
using namespace std;
int main()
Merge/purge: The technique of combining
Question 32
Question:
Solution:
#include<iostream>
1356
using namespace std;
int main()
Merge/Purge Problem:
{
int i =1;
do
A common problem involves the merging of data from
{
numerous sources with different representations in the
cout<<" \n i= "<< i++;
most effective and efficient manner possible while
} while (i<=5);
improving the correctness of the outcome
return 0;
}
Question 33
Question:
Missing data Sparse data
Write a program to print the output:
A large number of data All of the data points are
body [b] = b
points are unknown known − but the majority of
body [o] = o
them have zero value
body [d] = d
body [y] = y
Solution:
#include <iostream>
using namespace std;
Machine Discovery
int main()
{ Automated processes that make an effort to
1357
for(i=0; i<4; i++)
cout<<"\n body ["<<body[i] <<" ] = "<< body[i] << endl;
return 0;
}
Question 34
Question:
#include <iostream>
using namespace std;
int main()
Class: A label assigned to a group of records sharing
{
similar characteristics
cout<<"linux\n";
exit (0);
Epoch: The number of times a learning algorithm visits
Solution:
linux
1358
Question 35 Abduction: A form of reasoning where
assumptions are made to explain observations
Question:
Solution:
#include <iostream>
using namespace std;
int main()
Neural Machine Translation
{
int a =2;
if(isalpha(a))
{ The use of neural network
cout<<"The character a is an alphabet";
models to translate words
}
else from one language to
{ another
cout<<"The character a is not an alphabet";
}
return 0;
}
AI project based at the MIT Media Lab whose aim is to build a large
commonsense knowledge base from the contributions of the general public
over the web
A database holding all the general
knowledge that most people possess
1359
Question 36
Question:
Write a program to calculate the discounted price and the total price after
discount
Given:
Solution:
#include<iostream>
using namespace std;
int main()
{ Rule-based AI
double PV;
cout<<"Enter purchased value:";
cin>>PV;
if(PV>1000)
A system created to achieve AI via a
{
cout<<"Discount = "<< PV* 0.1 << endl;
model merely based on predetermined
1360
{
cout<<"Discount = "<< PV* 0.3 << endl;
cout<<"Total= "<< PV - PV* 0.3 << endl;
}
return 0;
}
Question 37
Question:
Write a program to print the first ten natural numbers using while loop statement.
Solution:
#include<iostream>
using namespace std;
int main() nouvelle AI
{
int i = 1;
while (i<=10) A sub field of AI that aims to produce robots
{ with intelligence levels alike insects
cout<<"\n "<< i++;
}
return 0;
}
Data Stewardship:
The process of guaranteeing an Enterprise organization's information is
1361
Question 38 Symbolic AI: The clear embedding of human knowledge and
behavior rules into computer programs
Question:
#include <iostream>
using namespace std;
int main() Model checking: The method of checking whether
{
the model meets a given specification
int i;
for (i=1; i<=5; i++)
Self-management
{
if (i==3)
{ The process by which machines
continue;
manage their own operations
}
cout<<"\n "<< i; without human intercession
}
return 0;
}
1
2
4
5
1362
Machine vision
Question
#include <iostream>
using namespace std;
#include <iostream>
int main() {
using namespace std;
int num [] = {11, 22, 33, 44, 55, 66};
int n; int main() {
n = sizeof(num) / sizeof(num[0]); int a = 25; // Now a is 25
cout<<"Size of the array is:"<<n; a = 50; // Now a is 50
/* Multi-line
Comment */
return 0;
Recommendation system
Information filtering system aimed at predicting what the users may like (based on
their previous activity or explicit feedback) and recommend products or services
that quite likely are interesting for them
1363
Question
1364
Question:
#include <iostream>
using namespace std;
Reasoning system
int main()
{
int i;
for (i=1; i<=5; i++) AI system that draws conclusions from available
{ knowledge using logical techniques such as
if (i==3) deduction and induction
{
break; idea → observation observation → idea
}
cout<<"\n "<< i;
}
return 0;
}
Solution:
1
2
#include<iostream>
using namespace std;
1364
int main()
{
int i;
Qualification problem
for(i=1;i<=5;i++)
{
if(i==3)
{ How to deal with the things that keep us
goto HAI; from accomplishing our intended result
}
cout<<"\n "<< i;
}
HAI : cout<<"\n Linux";
}
Solution:
1
2
Linux
#include<iostream>
using namespace std;
int main()
{
int i = 54;
int y = i<<1;
cout<<"The value of y = "<< y;
return 0;
}
1365
Solution:
#include<iostream>
using namespace std;
Serialization: The process of converting
int main()
data structures into a sequence of bytes which
{
can be stored in a database or transmitted
int i = 54;
through the network
int y = i>>1;
cout<<"The value of y = "<< y;
return 0;
}
The value of y = 27
#include<iostream>
#include<cmath>
Implement
using namespace std;
int main()
{
int a, b; Design Evaluate
a= - 2;
b= abs(a);
cout<<" Absolute value = "<< b<< endl;
return 0;
The iterative design cycle
}
1366
Solution:
Absolute value = 2
#include <iostream>
using namespace std;
Heuristic Search technique: A realistic
int main()
problem-solving strategy that reduce the
{
number of searches for best solution by
for( ; ; ) {
eliminates wrong choices
cout<<"This loop will run forever.\n";
}
return 0;
}
Solution:
#include<iostream>
Intelligent Enterprise Strategy: The management
using namespace std;
strategy that improves enterprise organizational
int main()
effectiveness by incorporating advanced technology,
{
best practices and new service models
cout<<"Hello World!";
1367
return 0;
cout<<"Hello World!";
}
Solution:
Hello,world!
Question 41
Question:
Solution:
#include<iostream>
using namespace std;
int main()
{
Data Relevancy: The degree to
int age;
which the content of data is helpful
age=20;
for the goal for which it is gathered
if(age > = 60)
{
cout<<"Senior citizen";
}
if(age<60)
{
cout<<"Not a senior citizen";
1368
}
return 0;
}
Question 42
Solution:
#include<iostream>
#include<math.h>
using namespace std; Timeliness of data: The information is
int main() available and accessible when required
{
int x = 20;
cout<<"Inverse of tan x = "<< atan(x); #include <iostream>
return 0; using namespace std;
} int main() {
int x = 2, y = 3;
double i;
i = (double)x/y;
1369
#include <iostream>
Solution: using namespace std;
int main() {
#include <iostream> string x, a("Alan"), b(" "), c("Turing");
using namespace std; x = a + b + c;
cout<<x;
int main() { return 0;
cout << max(25, 20); }
return 0;
} // Output: Alan Turing
Personality Insights
Question 44
#include <iostream>
Solution:
using namespace std;
#include <iostream>
#include <cmath>
int main() {
using namespace std;
cout << min(25, 20);
return 0; Output:
int main() {
} cout << sqrt(4) << "\n";
2
1370
Question 45
x += 5; is equivalent to x = x + 5;
x *= y + 4; is equivalent to x = x * (y+4);
Question:
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
void myFunc() {
int main() {
cout << "Albert\n";
cout.put('A');
}
return 0;
}
int main() {
myFunc();
myFunc(); // Output: A
myFunc();
return 0;
}
#include <iostream>
using namespace std;
int main() {
cout << "\nAlbert Einstein\t was a\n\t\t"
"German \"born\" theoretical physicist.\n";
return 0;
}
Output:
1371
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
int main() {
int main() {
double b = 15.569635;
double b = 15.569635;
cout.precision(4);
cout.precision(3);
cout << " " << b;
cout << " " << b;
return 0;
return 0;
}
}
// Output: 15.57
// Output: 15.6
#include <iostream>
#include <iostream>
#include <iomanip>
#include <iomanip>
using namespace std;
using namespace std;
int main() {
int main() {
double b = 15.569635;
double b = 15.569635;
cout << setprecision(4) << b;
cout << setprecision(3) << b;
return 0;
return 0;
}
}
// Output: 15.57
// Output: 15.6
#include <iostream>
#include <iomanip>
#include <iostream>
using namespace std;
using namespace std;
int main() {
int main() {
cout << setfill('*') << setw(4) << 15 <<endl;
float x(7.0);
cout << setfill('*') << setw(6) << 15 <<endl;
cout << x++ - 15.0/3.0;
return 0;
return 0;
}
}
// Output: 2
// Output:
**15
****15
1372
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
string x("Albert");
cout << right << setfill('?') << setw(12) << x;
return 0;
}
#include <iostream>
// Output: ??????Albert using namespace std;
int main() {
string x("AL"), y("BERT");
#include <iostream>
x += y;
#include <iomanip>
cout<<x;
using namespace std;
return 0;
int main() {
}
string x("Albert");
cout << left << setfill('?') << setw(12) << x;
// Output: ALBERT
return 0;
}
// Output: Albert??????
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
int main() {
int main() {
int x(24), y(73);
int x = -16;
cout << x++ << endl; // Output: 24
cout << -x;
cout << x << endl; // Output: 25
return 0;
cout << y-- << endl; // Output: 73
}
cout << --y << endl; // Output: 71
// Output: 16
return 0;
1373
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() { int main() {
int x = 0; int x = 0;
while( x < 5) while( x < 5)
cout << ++x << endl; cout << x++ << endl;
return 0; return 0;
} }
// Output: // Output:
1 0
2 1
3 2
4 3
5 4
#include <iostream>
using namespace std;
int main() {
int x = 3;
#include <iostream>
for (int i = -6; i < x; i++)
using namespace std;
cout << i << endl;
int x = 0;
return 0;
} namespace Special { int x = 50; }
int main() {
// Output:
cout << x << endl; // Output: 0
-6
cout << ++ ::x << endl; // Output: 1
-5
cout << -- ::x << endl; // Output: 0
-4
-3 cout << Special::x * 4 << endl; // Output: 200
-2 return 0;
-1
}
0
1
2
1374
#include <iostream>
#include <iostream>
using namespace std;
#include <list>
int main() { using namespace std;
int main(){
string x( 5, '+');
list<int> x = { 100, 200, 300, 400, 500 };
cout<< x;
cout<<"First element in the list is: "<< x.front() << endl;
return 0; cout<<"Last element in the list is: "<< x.back() << endl;
return 0;
}
}
// Output: +++++
// Output:
First element in the list is: 100
#include <iostream>
#include <list>
using namespace std;
// Output: 1 2 3 4 5
Computer Vision:
A branch of AI that deals with enabling machines to visualize, identify and derive meaningful
information from images and videos in the same way that a human being does
1375
Goodness of Fit
Dummy variable:
#include <iostream>
Amdahl's law:
x.remove(2);
cout<<'\n';
for (auto i = x.begin(); i != x.end(); ++i)
cout << ' ' << *i; // 1 3 4 5
return 0;
}
// Output:
1 2 3 4 5
1 3 4 5
Frequentist Statistics:
Predicate Calculus
A formal logical framework for displaying and reasoning with logical statements
1376
#include <iostream>
using namespace std; #include <iostream>
using namespace std;
void message()
{ int main()
cout << "Albert Einstein is waiting." << endl; {
} int x[] = { 20, 40, 60, 80 };
int main(){
message(); for (int i : x)
return(0); cout<< i <<" ";
}
}
// Output: Albert Einstein is waiting.
// Output: 20 40 60 80
Question 46
Question:
#include <iostream>
#include <iostream>
#include <vector>
using namespace std;
using namespace std;
int main()
int main() {
{
vector<int> x{11, 12, 13, 14, 15};
int x[] = { 20, 40, 60, 80 };
if (x.empty()) {
cout << "True";
for (auto i : x)
}
cout<< i <<" ";
else {
cout << "False";
}
}
return 0;
// Output: 20 40 60 80
} Output: False
1377
#include <iostream>
#include <vector>
using namespace std; #include <iostream>
using namespace std;
int main() { #define concat(x, y) x ## y
vector<int> x{};
if (x.empty()) { int main() {
cout << "True"; int ab = 125;
}
else { cout << concat(a, b);
cout << "False"; return 0;
} }
return 0;
} // Output: 125
// Output: True
#include <iostream>
using namespace std;
int main () {
cout << __LINE__ << endl; // Line number: 4
cout << __FILE__ << endl; // File name: main.cpp
cout << __DATE__ << endl; // Date: Jul 20 2022
cout << __TIME__ << endl; // Time: 16:58:55
return 0;
}
AI Adoption:
1378
Question 47
Question:
Solution:
#include <iostream>
using namespace std;
case 'b':
cout<<"Albert Einstein\n";
break;
P-hacking: The inappropriate
Data Exhaust:
default: cout<<"Wolfgang Pauli\n";
break; The unstructured data generated as a
} byproduct of the online activities of internet
return 0;
users. For Example: cookies, log files and
temporary internet files are generated and
}
deposited by web browsers and their plugin in
the user's computer
// Output: Max Born
1379
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<string> i{ "Albert",
// Output:
"James",
"Alan"}; Albert
James
for (const auto& b : i) { Alan
cout << b << '\n';
}
return 0;
}
extern "C" {
int printf(const char* format, ...);
#include <iostream>
}
#include <iostream>
using namespace std;
int main() {
do{ Infinite Loop
cout << "Hi....\n";
} while(1);
return 0;
}
1380
#include <iostream>
using namespace std;
int main() {
char ch;
cout << "Please enter a character: ";
cin >> ch;
cout <<"Integer equivalent of " << ch << " is: " << static_cast<int>(ch) << endl;
return 0;
}
// Output:
Please enter a character: A # entered character
Integer equivalent of A is: 65
#include <iostream>
using namespace std; // Output:
int main() {
????
int i = 1;
while (i <= 6) { #######
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 15;
if (a < 12) {
if (b > 12) // Output:
cout << "??????" << endl;
} ??????
else {
cout << "********" << endl;
cout << "#######" << endl;
}
return 0;
}
1381
Question 48 • Qualitative Data: Data that can be described, categorized and expressed in terms of
Question: • Quantitative Data: Data that can be measured, counted and easily expressed using numbers
#include <iostream>
#include <iostream>
using namespace std;
int main() {
int b = 28, a =25;
if (b == 28) // Output:
if (a == 25) {
cout << "+++++++\n"; } +++++++
else {
*******
cout << "-------\n";
} @#@#$$$$
cout << "*******\n";
cout << "@#@#$$$$\n";
return 0;
}
1382
// C++ program print the sum of the odd numbers from 1 to 25
#include<iostream>
Data generalization: The process of deriving
using namespace std;
conclusions from a small amount of data
int main() {
int n, x, sum = 0;
cout <<"\n Odd numbers between 1 and " << x << " is: ";
for(n = 1; n <= x; n++){
if ( n % 2 != 0 ) {
cout << n << " ";
sum = sum + n;
}
}
cout << "\n The sum of the odd numbers from 1 to " << x << " = " << sum;
return 0;
}
// Output:
Data Profiling: The process of evaluating, exploring, analyzing, reviewing the data
available from an existing information source and producing useful summaries of data to
1383
#include<iostream>
using namespace std; // Output:
cout << "\n The sum of all ASCII values: " << sum;
return 0;
}
Deep Learning:
Python code:
Multithreading: A method of simultaneously handling
x=0
x=x+a Long Polling: A web application development strategy for
print(x) # Output: 4 pushing data as soon as possible from servers to clients
1384
CORS Utterance:
(Cross-Origin Resource Sharing): Any human user's input into a Chabot
Java Exercises
Admissibility: An algorithm's ability
to always discover the best solution
Question 1
Handwriting Recognition: A computer machine's
Solution:
1385
Question 2 Logical mathematical intelligence: The ability to
think logically about problems and solve them using
logical and mathematical methods
Question:
Solution:
r = 2; experienced events
area = 3.14 * r * r;
System.out.println("The area of the circle = " + area);
}
}
Question 3
Question:
1386
int a, b, sum;
a=1;
b=2;
C++ Program:
sum = a + b;
System.out.println("The sum of a and b = " + sum); #include <iostream>
} using namespace std;
} int main() {
string x("Alan "),y("Turing");
cout << x + y << endl;
// Output: Alan Turing
x += y;
cout <<x << endl;
// Output: Alan Turing
Question 4 x += "!";
cout <<x;
// Output: Alan Turing!
Question: return 0;
}
1387
# Python code to print the minimum and maximum values present in a tuple
Question 5
tuple=(4,5,6,7,8)
Output on the screen:
4
print(min(tuple))
8
Question: print(max(tuple))
b =3; cout << "The element at index 3 is: " << x[3] << endl;
// Output: The element at index 3 is: 14
if(a>b)
return 0;
{
}
System.out.println("a is greater than b");
} x.at(i) is equivalent to x[i]
else
{
System.out.println("b is greater than a");
}
}
}
Question 6
Question:
1388
Solution:
Question 7
Question:
Write a program such that a Switch (case) allows to make a decision from the
number of choices, i.e., from the number of cases.
1389
switch(ch)
{
case 'R':
Overlaying: The technique of replacing what
System.out.print("Red");
is already stored in internal memory with a
break;
block of software code or other information
case 'W':
System.out.print("White");
break;
case 'Y': Reentrancy:
System.out.print("Yellow");
During the same time period, many users can use
break; and share a single copy of a program
case 'G':
System.out.print("Green");
break;
default: Context Switching:
System.out.print("Error");
A method of preserving the state of one process
break;
and loading the state of another process
}
}
}
Question 8
Question:
Write a program to read 10 numbers from the keyboard and find their sum and
average.
1390
import java.util.Scanner;
public class MyClass {
# Python code to check the memory usage of integer
public static void main(String [] args) {
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, sum; import sys
float X; a = 25
Scanner scan = new Scanner(System.in);
print(sys.getsizeof(a))
System.out.println("Enter any ten Numbers: ");
N1 = scan.nextInt();
N2 = scan.nextInt();
N3 = scan.nextInt(); Abstraction
N4 = scan.nextInt();
N5 = scan.nextInt();
N6 = scan.nextInt();
N7 = scan.nextInt(); Hiding unnecessary data and executing necessary data
N8 = scan.nextInt();
N9 = scan.nextInt();
N10 = scan.nextInt();
sum = N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9 + N10;
X = sum /10;
System.out.println("The sum of 10 numbers = " + sum);
System.out.println("The average of 10 numbers = " + X);
}
}
Question 9
Question:
Write a program to print the first 10 numbers starting from one together with
1392
Solution:
System.out.println(" \n number = " + i + " its square = " + i*i + " its cube = " +i*i*i);
}
Question 10
Solution:
1393
Question 11
Question:
Solution:
import java.util.Scanner;
public class MyClass { Installation and checkout phase:
public static void main(String [] args) {
int n, i; During this stage of the software development
Scanner scan = new Scanner(System.in); life cycle, a software application is integrated
System.out.println("Enter a number: "); into its operational environment and tested there
n = scan.nextInt(); to ensure that it performs as expected
for( i=1; i<=5; i++)
System.out.println (n + " * " + i + " = " + n * i);
}
}
Question 12
Question:
1393
Solution: DML
Question 13
Question:
Solution:
1394
}
}
Question 14
Question:
Solution:
TCL
(Transaction Control Language)
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int x, y; A computer language used to save and restore
Scanner scan = new Scanner(System.in); changes to a database
System.out.println("Enter a number: ");
x = scan.nextInt();
System.out.println("Enter a number: ");
y = scan.nextInt();
if(x-y==0) DQL
{
(Data Query Language)
System.out.println("The two numbers are equivalent");
}
else
{ A computer language used to create
1395
Question 15
Question:
Solution:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
RDBMS DBMS
int a, b, c; (Relational Database Management system) (Database Management System)
Scanner scan = new Scanner(System.in); Data stored is in table format Data stored is in the file format
System.out.println("Enter a number: "); Deal with vast amount of data Deal with small amount of data
a = scan.nextInt();
System.out.println("Enter a number: ");
b = scan.nextInt();
c = a%b;
System.out.println("The remainder of a and b = " + c);
}
}
1396
Solution:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int a;
Thrashing:
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number: "); A situation in which there are a lot of paging operations
a = scan.nextInt();
if(a%2 == 0)
{
System.out.println("The number is even"); A storage technique that allows the operating system to fetch
} processes in the form of pages from secondary storage and
else store them in the main memory
{
System.out.println("The number is odd");
}
}
}
Bug Release:
Solution:
With the understanding that a bug exists, a software
public class MyClass { application is delivered to the testing team
1397
Mean Substitution:
public static void main(String [] args) { The method of replacing missing values with
char a; mean of other available values
for( a='A'; a<='Z'; a++)
System.out.println("\n " + a);
}
} #include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() { int main() {
string x("Albert"); string x("Albert");
x.erase(3); x.insert(3, "Mary");
cout<<x; // Output: Alb cout<<x; // Output: AlbMaryert
Question:
numbers.
1398
}
#include <iostream>
Question 19 using namespace std;
int main() {
string x("Albert Einstein");
Question: x.erase(2,4);
cout<<x; // Output: Al Einstein
Solution:
1399
Solution:
import java.util.Scanner;
public class MyClass {
public static void main(String [] args) {
int a, b, c;
Scanner scan = new Scanner(System.in);
System.out.println("Enter any number:");
a = scan.nextInt();
System.out.println("Enter any number:");
b = scan.nextInt(); Data Ecosystem: A platform
System.out.println("Enter any number:"); that collect, analyze and store data
c = scan.nextInt();
if(a>b&&a>c)
{
System.out.println("a is greater than b and c");
}
else if(b>a&&b>c)
Data Hygiene: The process of ensuring
{
that an enterprise organization has error-free,
System.out.println("b is greater than a and c");
updated, consistent and accurate data
}
else
{
System.out.println("c is greater than b and a");
}
}
}
BYOD
A policy that allows employees in an enterprise organization to use their personal smartphones,
laptops and tablets to access enterprise data from anywhere
1400
Question 21 Crystal Methodology: An agile software development strategy
that prioritizes individuals and their interactions rather than
techniques and methodologies when working on a project
Question:
#include <iostream>
1401
Solution:
import java.util.Scanner;
public class MyClass { Control program: A computer
public static void main(String[] args) { program that controls and manages
String a; the operation of a computer
Scanner scan = new Scanner(System.in);
System.out.print("Enter Your Name : ");
a = scan.nextLine();
System.out.println("The length of the String is: " + a.length());
}
}
Question 23
Einstein [1] = I
Einstein [2] = N
Einstein [3] = S Compile time
Einstein [4] = T
Einstein [5] = E
The time it takes for a computer program to be built
Einstein [6] = I into an executable file
Einstein [7] = N
1402
Solution:
Question:
Solution:
import java.util.Scanner;
public class MyClass {
Concurrent server: A server that can
public static void main(String[] args) {
handle multiple clients at once
int x;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number: ");
x = scan.nextInt();
System.out.println("Square of the number = " + square (x));
}
public static int square (int x){
return x*x;
}
1403
}
Question 25
Write a program To print "hello world" 10 times. completeness and consistency of data
Solution:
Question 26
Question:
Solution:
1404
public class MyClass {
public static void main(String [] args) {
int i =1;
Cryptographic algorithm: A collection
do
of rules describing the mathematical steps
{
needed to encrypt and decrypt
System.out.println(" \n " + i++);
} while (i<=5);
information
}
}
Question 27
Question:
Cryptography
Solution:
1405
}
Question 28
Question:
Write a program to print the first ten natural numbers using while loop statement.
} High bias machine learning algorithms include: Linear Regression and Logistic Regression
Question 29
1406
Data Strategy
public class MyClass {
public static void main(String []args) {
The method of defining how to collect, store,
int i;
manage, share and use data in support of business
for (i=1; i<=5; i++) {
and technology objectives
if (i==3) {
continue;
}
System.out.println("" + i);
}
} • Interpolation → Predicting values that are inside the range of data taken (Reliable)
} • Extrapolation → Predicting values that are outside the range of data taken (Unreliable)
Solution: }
1407
public class MyClass {
public static void main(String[] args) {
int num [] = {11, 22, 33, 44, 55, 66};
System.out.println("Size of the array is: " + num.length);
}
} 0 1 2 3 4 5 6 7 8 9 10
'A' 'l' 'b' 'e' 'r' 't' '' 'J' 'o' 'h' 'n'
break; The process of gathering and The process of breaking down the
} combing data from various sources aggregated data into smaller units
System.out.println("" + i); and presenting it as a whole for of data to elucidate trends and
} statistical analysis patterns that are masked by
} aggregated data
}
Data Aggregation: Collect the data → Process the data → Present the data
Solution:
1
2
1408
Denial-of-Service: A malicious attempt in which
public class MyClass { the perpetrator bring a system or network to a halt,
public static void main(String [] args) { making it unavailable to its intended users
int x = 2;
System.out.println(" Square of a number = " + Math.pow((x), 2));
#include <iostream>
}
using namespace std;
}
int main() {
string x = "Alberg";
x[x.length() -1] = 't';
cout<<x;
Solution:
int i = 54;
1409
int y = i>>1;
System.out.println("The value of y = " + y); Network security: the technique for
} protecting a computer network from
} unauthorized access and malicious attacks
Solution:
The value of y = 27
import java.util.Scanner;
public class MyClass { Clickjacking: A malicious technique of scamming website
public static void main(String [] args) { visitors to click on user interface components that perform
1410
public static void main(String[] args) {
for( ; ; )
{ Vulnerability Assessment: A method for
System.out.println("This loop will run forever.\n"); identifying, detecting, and analyzing
} security flaws in a computer system
}
}
Solution:
Solution:
Hello,world!
1411
Question 32
Question:
Solution:
Question 33
1412
Solution:
Data At Rest Encryption (DARE):
public class MyClass {
Data at rest
public static void main(String[] args) {
char ch = 'a';
The encryption of data which is stored in databases
int ascii = ch; but not transmitted over networks
int castAscii = (int) ch;
Question: }
Inconsistency management
Solution:
• Recognize inconsistency
public static void main(String[] args) {
• Manage inconsistency
1413
float first = 12.0f, second = 24.5f;
System.out.println("Before swap:");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
System.out.println("After swap:");
}
// returns true, because 20 is greater than 19
System.out.println(a > b); // Output: true
// Output: 5220
}
}
1414
Question 35
Question:
Solution:
1415
import java.util.*;
Question 36
Question:
Solution:
1416
Question 37
Question:
import java.util.*;
public class MyClass {
public static void main(String[] args) {
String x = "Albert Einstein was a German-born theoretical physicist.";
String[] i = x.split("[ ]+");
System.out.println(i[i.length - 2]);
}
}
// Output: theoretical
1417
Question 38
Question:
Write a program to print numbers between 1 to 50 which are divisible by 2, 4 and by both
Solution:
System.out.println("\n");
System.out.println("\n");
1418
Question 39
Question:
while(x != 0) { }
Albert
}
x /= 10;
Albert
++i;
Albert
}
// Output:
public class MyClass {
public static void main(String[] args) {
Eins
String x = "Einstein";
System.out.println(x.substring(0, x.length()/2));
}
}
1419
Question 40 public class MyClass {
static {
System.out.println("Albert Einstein");
Question: }
public static void main(String[] args) {
// Output:
Alan Turing
if(x == y) }
} // Output:
System.out.println("Equal");
}
else Alan
System.out.println("Not Equal"); Alan
} Alan
}
System.out.println(System.getProperty("user.dir"));
1420
public class MyClass {
public static void my2(int[]... i) {
for(int[] z:i) {
System.out.println(z[1]);
// Output:
}
}
2
public static void main(String[] args) {
6
int[] x = {1,2,3,4};
int[] y = {5,6,7};
my2(x, y);
}
}
} Alan Turing
System.out.println("Alan Turing");
1421
public class MyClass {
public static void main(String[] args) {
// Output:
if (false) {
System.out.println("Albert Einstein");
Alan Turing
}
System.out.println("Alan Turing");
}
}
1422
public class MyClass {
public static void main(String[] args) { // Output:
int x=0;
Albert
for(System.out.println("Albert");x<3;x++) {
Einstein
System.out.println("Einstein");
Einstein
}
Einstein
}
}
// Infinite loop
1423
public class MyClass {
public static void main(String[] args) {
for(int x=0;x<2;System.out.println("Alan"),System.out.println("Albert")) {
System.out.println("John");
x++;
// Output:
}
John
}
Alan
}
Albert
John
Alan
Albert
// Output: 50
// Output: 50
1424
public class MyClass {
public static void main(String[] args) { // Output:
int[] x={1,2,3,4};
1
for(int y:x) {
2
System.out.println(y);
3
}
4
}
}
x[1]=10; }
x[2]=15; }
for(String i : x) { Alan
System.out.println(i); Mathison
} Turing
}
}
1425
public class MyClass {
public static void main(String[] args) {
char[] x={'A','J','o','h','n','l','b'}; public class MyClass {
String y=new String(x,1,4); public static void main(String[] args) {
System.out.println(y); StringBuffer x=new StringBuffer("Albert");
} System.out.println(x.delete(1,4));
} // Output: Art
}
// Output: John }
// Output: cdef
1426
public class MyClass {
public static void main(String[] args) {
StringBuffer x =new StringBuffer("Five");
String i=" Papers of ";
// Output:
int y=1905;
x.append(i);
Five Papers of 1905
x.append(y);
System.out.println(x);
}
}
1427
import java.util.*;
public class MyClass {
public static void main(String[] args) {
Stack x=new Stack();
x.push("Einsteinian"); // Output:
x.push(1905);
x.push("Papers"); [Einsteinian, 1905, Papers]
System.out.println(x);
}
}
import java.util.*;
public class MyClass {
public static void main(String[] args) {
HashSet x=new HashSet();
// Output:
x.add("Albert");
x.add("Papers");
[null, 1905, Papers, Albert]
x.add(1905);
x.add(null);
System.out.println(x);
}
}
import java.util.*;
public class MyClass {
public static void main(String[] args) {
HashSet x=new HashSet();
x.add("Albert");
x.add("Albert");
x.add("Papers"); // Output:
x.add(1905);
x.add(1905); [null, 1905, Papers, Albert]
x.add(null);
System.out.println(x);
}
}
1428
import java.util.*;
public class MyClass {
public static void main(String[] args) {
TreeSet x=new TreeSet();
x.add(35);
x.add(15);
x.add(25);
x.add(10);
x.add(30);
SortedSet a=x.headSet(35);
System.out.println(a); // Output: [10, 15, 25, 30]
SortedSet b=x.tailSet(25);
System.out.println(b); // Output: [25, 30, 35]
SortedSet c=x.subSet(15,35);
System.out.println(c); // Output: [15, 25, 30]
}
}
import java.util.*;
x.put("Albert", 1978);
x.put("John", 1965);
// Output:
x.put("James", 1945);
{James=1945, John=1965, Albert=1978}
System.out.println(x);
1429
import java.util.*;
x.put("Albert", 1978);
x.put("John", 1965);
x.put("James", 1945);
System.out.println(x);
System.out.println(x.contains(1945));
// Output: true
System.out.println(x.containsValue(1988));
// Output: false
1430
Question 41
Question:
Write a program to print the sum of even numbers from 1 to 10 using for loop
}
}
System.out.println("The sum of even numbers from 1 to 10 is: "+sum);
}
}
1431
Question 42 public class MyClass {
public static void main(String[] args) {
System.out.println("20 > 19 is " + (20 > 19));
// Output: 20 > 19 is true
Question: }
}
Solution:
System.out.println(x);
}
}
// Output: Albert
1432
Question 43
Question:
Solution:
// A buzz number is any number that either ends with 7 or is divisible by 7.
import java.util.Scanner;
// Output:
public class MyClass {
public static void main(String[] args) {
Enter a number:
Scanner in=new Scanner(System.in);
127 # entered number
System.out.println("Enter a number:");
127 is a Buzz Number
int x = in.nextInt();
if(x%7==0 || x%10==7) {
System.out.println(x + " is a Buzz Number");
} else {
System.out.println(x + " is not a Buzz Number");
}
}
} public class MyClass {
public static void main(String args[]) {
public class MyClass { int y = 20;
public static void main(String[] args) { for(int i = 0; i<5; i++) {
int a = 20, b = 60;
System.out.println(y);
if(a < b) System.out.println("a<b");
y = y - 2;
// Output: a<b
} // Output:
a = a * 3;
} 20
if(a == b) System.out.println("a=b");
// Output: a=b } 18
a = a * 3; 16
if(a > b) System.out.println("a>b"); 14
// Output: a>b 12
}
}
1433
Question 44
Question:
Write a program to check if 20 appears as either the first or last element of an array
of numbers
Solution:
import java.lang.*;
public class MyClass {
public static void main(String[] args) {
int[] x = {20, 40, 0, 60, 70, 80, 20};
System.out.println((x[0] == 20 || x[x.length-1] == 20));
// Output: true
}
}
// Output: 60
// Output: 20
1434
Question 45
Question:
Write a program to check if the first and the last element of an array of numbers are same
Solution:
import java.lang.*;
public class MyClass {
public static void main(String[] args) {
int[] x = {50, 10, 0, 20, 30, 40, 50};
System.out.println (x.length >= 2 && x[0] == x[x.length-1]);
// Output: true
}
}
1435
public class MyClass {
public static void main(String[] args) {
int x[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
System.out.println("February has " + x[1] + " days.");
}
}
// Output: February has 28 days.
System.out.println("i<5");
// Output:
break;
5
default: 4
System.out.println("i=5 or i>5"); 3
2
}
1
// Output:
}
i>3
}
i>3
i<5
i<5
i=5 or i>5
1436
public class MyClass {
public static void main(String[] args) {
int x = 10, y = 20;
while(++x < --y) ;
public class MyClass {
System.out.println(x);
public static void main(String[] args) {
}
int x = 5;
}
do {
System.out.println(x);
// Output: 15 // Output:
} while(--x > 0);
} 5
} 4
3
Question 46 2
1
Question:
Write a program to add all the digits of a given positive number until the result has a single digit
Solution:
// Output: 4
// 1 + 2 + 6 + 4 = 13
// 1 + 3 = 4
1437
public class MyClass {
public static void main(String args[]) {
int x;
x = 'C';
System.out.write(x);
System.out.write('\n');
}
}
// Output: C
import java.io.*;
public class MyClass {
public static void main(String args[]) {
PrintWriter x = new PrintWriter(System.out, true);
x.println("Albert Einstein");
}
}
1438
import java.util.*;
78
public class MyClass {
public static void main(String args[]) {
Formatter x = new Formatter();
x.format("%s spends between $%d and $%f annually for books" , "John", 100, 198.6);
System.out.println(x);
}
}
// Output: John spends between $100 and $198.600000 annually for books
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Formatter x = new Formatter();
x.format("|%f|%n|%10f|%n|%010f|",54.98765, 54.98765, 54.98765);
System.out.println(x);
} public class MyClass {
// Output: }
|054.987650| }
}
1439
import java.io.*;
public class MyClass {
public static void main(String args[]) {
Console con;
con = System.console();
con.printf("Albert Einstein");
}
}
import java.util.regex.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
1440
// Java program to print the Unicode of the first character in a string
// The Unicode value of "A" is 65
1441
// Java program to print the hash code of a string
1442
public class MyClass {
int i;
public MyClass(int i) {
this.i = i;
}
{ int i = 50;
// Output: 1905
System.out.println(i); }
}
public class MyClass {
}
static int my2(int i) {
return 5 * i;
// Output: 50
}
// Output: 60
System.out.println("Albert");
// Output: Albert
1443
public class MyClass {
}
}
1444
import java.util.*;
1445
import java.util.*;
import java.util.*;
// Check for the emptiness of stack public class MyClass {
// Is the stack empty ? public static void main(String[] args) {
System.out.println(x.empty()); System.out.println("Time to wake-up: ");
}
}
1446
public class MyClass {
// Output:
public static void main(String[] args) {
1
for(int x = 1; x <= 20; x += 2) { 3
5
System.out.println(x);
7
} 9
11
}
13
} 15
17
19
public static void main(String[] args) { public static void main(String[] args) {
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Which is the best place in the World to visit?");
int x = 0;
do { The user is given a menu of options by
System.out.println("1. Machu Picchu, Peru"); the program. Since there are only 3
1447
Two-factor authentication (2FA): Perimeter-based Cybersecurity:
Users authenticate their identification using two-step The idea of securing data and IT resources from
verification steps in this security mechanism hackers by putting security measures in place at the
network's perimeter
Autonomic Computing
Information Theory: The mathematical study of determining how much information there is in a message
Product personalization
The customization of products and services according to the needs or desires of the customers
1448
Moore's Law
System.out.println("Albert Einstein");
Polymorphic virus:
1449
public class MyClass {
Usability Testing: A software testing technique used to evaluate the software's usability
Data Ingestion: The process of collecting raw Project data analytics: The collection and
data from various sources and bringing it into a analysis of past and current project data to make
data processing system where it can be stored, worthwhile decisions on project delivery
examined and accessed
return a + 2 * a;
}
// Output:
12
public static void main(String[] args) {
System.out.println(my2(4));
1450
Security Testing: A sort of software testing that identifies security flaws, cyber-attacks
and potential risks in a software application and guards against hacker attacks
End to End testing: The entire process of testing a software application from beginning to end
One that must exist for an event to take place One that will cause the event to occur
Fan-in: The largest number of digital inputs a single logic gate can receive
Fan-out: The largest number of digital inputs that a single logic gate's output can sustain
A detailed explanation of all the data required to build a working system from
1451
public class MyClass {
} else {
} // Output:
Soft state:
Even without input, the status of the system may vary with time
1452
Latent defect: A type of flaw or bug that has been present in a software application
for so long but has only now been detected
enum names {
Albert,
James,
Mary
Data encrypting key: A key that can be used to Data streaming: The continuous transmission
encrypt, decrypt and authenticate data of data at a high speed
1453
Traditionally,
ML algorithms rely on smaller data sets in order to reach logical conclusions more quickly
enum names {
Albert,
James,
Mary
// Output:
}
Albert
public static void main(String[] args) {
James
for (names i : names.values()) {
Mary
System.out.println(i);
Deep computing
(High-speed computing + Complicated analytical programs)
Allows business decision makers to evaluate, detect patterns in and act on gathered data in order to generate
significant solutions to extremely complex and tough problems
1454
Delta: The differences between 2 programs Down: Not working
enum names {
Albert,
James,
Mary
// Output:
public class MyClass {
Mary
public static void main(String[] args) {
names i = names.Mary;
System.out.println(i);
Dump: A location where all available data about a other technical issues
problem is stored in piles
1455
Artificial Neuron
A digital construct that imitate closely the behavior of a biological neuron in the human brain
Pruning:
The process of removing unnecessary and inaccessible code so as to make the code more readable, easily
maintainable and to eliminate unwanted solutions
Early stopping: A feature that allows the Computational Linguistics: The discipline of
training to be stopped automatically when a linguistics concerned with the analysis and synthesis
given metric stops progressing of language and speech using computers
1456
enum names {
switch(i) {
break;
case Alan:
System.out.println("Alan Turing");
break;
case Hilbert:
System.out.println("David Hilbert");
break;
// Output:
Alan Turing
}
1457
Data flow testing: The data flow is examined in relation to the variables used in the software program
Testbed: A piece of software equipment that is Test report: A report that contains a concise
used for testing of a software application in a overview of the testing goals, methods,
precise, transparent, and consistent manner procedures and findings
Test deliverables: The reports or documents generated during the testing process
// Output: 3.048582995951417
} Browser automation:
Test matrix: A software testing equipment A method of automatically evaluating the functioning of a
that records the overall quality, resources, web application in a browser, in which a software program
concentrated effort, strategy, and time spent opens the web browser, traverses to the application, and
on each phase of software testing performs actions, much like a normal user would
A use case
Describes how a machine will execute a particular task if particular conditions are met
1458
Data Engineer: A data professional in Data Pipeline: A method of automating data
charge of getting the appropriate data into flow across an enterprise organization by
the hands of data scientists and analysts extracting, transforming and loading data to a
destination for storage and analysis
Random Forest
Blockchain: A data storage technology that
A supervised learning approach that combines
makes it extremely difficult or impossible to
the outputs of several decision trees into a single
edit, hack or fake the data − thereby making the
model and is commonly employed in regression
data secure and unchangeable
and classification issues
System.out.println("+********+ ");
[| @ @ |]
System.out.println(" { '=' } ");
( <> )
System.out.println("+#######+ ");
{ '=' }
}
+#######+
}
1459
Market Mix Modeling:
Solution requirements: Specific
A technique for determining how various features that a product must have in
promotional strategies influence a product's
order to meet business requirements
business Key performance metrics
Watson
Monkey testing:
Guarantees that the software application is suitable for
use in that particular region A type of software testing technique that
evaluates the behavior of the software
application and validates whether it crashes
Benchmark Testing: The practice of evaluating an
or not based on certain random inputs
application's performance against an industry standard set
without any predefined test cases
by another enterprise organization
1460
Python Exercises Data Refinement: The method of
standardizing, categorizing, tagging
and streamlining data to empower
necessary business decisions
print("A 6'2\" tall object")
Question 1
# Output: A 6'2" tall object
print('A 6\'2" tall object')
Solution:
a = 1
b = 2
c= a+b
print(c)
ELIZA Effect
The tendency to unconsciously presume computer behaviors are comparable to human behaviors
1461
Question 2
Question:
Write a program to find whether a given number (accept from the user) is even or
odd, print out an appropriate message to the user.
Solution:
Biometrics
a = int(input("enter a number: "))
if a % 2 == 0: People are identified and authenticated using technology
print("This is an even number.") based on their distinct physical and behavioral features
else:
print("This is an odd number.")
Question 3
Question:
negative or zero.
Solution:
1462
print("Positive number")
elif a == 0: Comparative analysis: The process of comparing
print("Zero") and contrasting 2 or more data sets in order to
print("Negative number")
Question 4
Question:
Solution:
Data aggregation tools
import calendar
Tools for combining data from numerous sources into a single
yy = int(input("Enter year: "))
location in order to prepare the combined data for data processing
mm = int(input("Enter month: "))
print(calendar.month(yy, mm))
Question 5
Question:
Write a program to ask the user to enter the string and print that string as output
of the program.
1463
Solution:
print(x.substitute(ab="Alan"))
Question 6 print(x.substitute(ab="John"))
Question:
Reporting Performance
Question 7
The system's ability to generate reports
quickly and effectively in response to
Question: queries from end users
1464
list_of_items = ["ball", "book", "pencil"]
item = input("Type item to check: ")
Data feed: A way of getting updated information
if item in list_of_items:
from data sources such as a Twitter feed or RSS
print("Item exists in the list.")
else:
print("Item does not exist in the list.")
Question 8
Solution:
print(finalList)
Question 9
1465
Solution:
import math
a = int(input("Enter a number: ")) Load balancing: The process of distributing incoming network
b=math.pow(a,3) traffic across numerous servers in an efficient manner
print (b)
Question 10
Question:
Fault-tolerant design
Solution:
import math
A system that is designed to keep running
a = int(input("Enter a number: "))
even if some of its components fail
b=math.sqrt(a)
print (b)
Question 11
Question:
Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25])
and makes a new list of only the first and last elements of the given list.
1466
Solution:
Question 12
Question:
Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and
write a program that prints out all the elements of the list that are less than 5.
A branch of statistical learning theory which aims to examine ML problems and algorithms
1467
Algorithmic AI bias
Question 13
Let's say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].
Write one line of Python that takes this list 'a' and makes a new list that has only
the even elements of this list in it.
Solution:
Question 14
Question:
Ask the user for a string and print out whether this string is a palindrome or not (A
Solution:
1468
if list(c) == list(b):
print("It is palindrome")
else:
print("It is not palindrome")
Question 15
Question:
Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b =
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that
contains only the elements that are common between the lists (without
duplicates). Make sure your program works on two lists of different sizes.
Solution:
Question 16
1469
Solution:
file = open("testfile.txt","w")
file.write("Hello World")
file.write("This is our new text file")
file.write("and this is another line.")
file.write("Why? Because we can.")
file.close()
Question 17
Question:
with open('testfile.txt') as f:
Abnormal termination of the execution of
line = f.readline()
while line:
a program prior to completion
print(line)
line = f.readline()
Data Curation: The organization and integration of data collected from various sources
1470
Question 18
Data Machine Learning Predictive model
Question:
Take two sets, say for example these two: a = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89} b =
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13} and write a program that returns a set that
contains only the elements that are common between the sets.
Solution:
Question 19
Question:
Write a program to split the characters of the given string into a list.
Solution:
Programmatic Advertising:
s = "mystring"
l = list(s) The automated process of buying and
print (l) selling of online advertising
1471
Question 20
Question:
Create a program that asks the user for a number and then prints out a list of all
the divisors of that number.
Solution:
Question 21
Solution:
1472
c = int(input("Enter third number: "))
if (a > b) and (a > c):
largest = a Installation Testing: A Testing that is carried out to ensure that the
elif (b > a) and (b > c): software application has been installed properly with all of its inherent
largest = b features and that the software application is functioning as intended
else:
largest = c
print("The largest number is", largest)
Sampling bias:
Imagine that there are 10 individuals in a bakery and if you are asked to survey whether they like
butter or jam. If you only surveyed the 3 individuals and concluded that the majority of
individuals like butter, you'd have exhibited a sampling bias
1473
Question 23
Question:
Question 24
Question:
1474
Question 25
Question:
Write a program to calculate the sum and average of Natural Numbers from 1 to
N.
Solution:
Question 26
Question:
Solution:
1475
n = int(input("Please Enter any Number: "))
for i in range(n):
print("hello world")
Question 27
Question:
Question 28
Question:
1476
System administrator
Solution:
Question 29
Question:
XML Database
Solution:
Question 30
Question:
Solution:
1477
list1 = ["pen", "book", "ball"]
a = len(list1)
print(a)
Question 31
Question:
Write a program To calculate the variance and standard deviation of the elements
of the list.
Solution:
import numpy as np
a= [2,6,8,12,18,24,28,32] Performance testing: The process of determining how well
variance= np.var(a) a computing machine performs in terms of speed,
std = np.std(a) responsiveness and stability under a specified workload
print(variance)
print(std)
Question 32
Question:
1478
Solution:
list1 = [4, 5, 6, 7]
list2 = [4, 5]
print(list(set(list1) - set(list2)))
Question 33
Question:
Question 34
Question:
Write a program that prints all the numbers from 0 to 6 except 2 and 6.
1479
for x in range(6): Microservices: An architectural approach in which a
if (x == 2 or x==6): single application is developed as a collection of small
continue independent services that perform specific functions and
print(x) communicate over well-defined APIs
Question 35
Question:
Write a program that takes input from the user and displays that input back in
upper and lower cases.
Synthetic monitoring:
Question:
1480
Solution:
string = "myw3schools.com"
print(string.startswith("w3s"))
Question 37
Question:
Solution:
Column-oriented database: A database in which data is
for i in range(1,11):
print(n,'x',i,'=',n*i)
Question 38
Question:
Confabulation
Solution:
1481
print("Enter lengths of the triangle sides: ")
a = int(input("a: ")) • Hot data storage: The storage of data that is accessed frequently.
b = int(input("b: ")) • Warm data storage: The storage of data that is accessed less frequently
c = int(input("c: "))
• Cold data storage: The storage of data that is rarely accessed
if a == b == c:
print("Equilateral triangle")
elif a==b or b==c or c==a:
print("isosceles triangle")
else: Prometheus
print("Scalene triangle")
A freely available tool created to support
tracking and reporting in cloud-native
platforms, such as Kubernetes
Question 39
Question:
Write a program to sum of two given integers. However, if the sum is between 15
to 20 it will return 20.
Solution: CRUD
(Create, Read, Update, Delete)
a = int(input("enter a number: "))
b = int(input("enter a number: "))
c= a+b
if c in range(15, 20): The four basic operations for manipulating the stored data
print (20)
else:
print(c)
Incident Response
1482
Question 40 Cross-channel analytics: The process of collecting, evaluating and presenting
data from a wide range of marketing channels in one location in order to
investigate how customers are impacted to purchase a product or service
Question:
pi=22/7
degree = int(input("Input degrees: "))
A cloud-based database that is rented on a per-use basis
radian = degree*(pi/180)
print(radian)
Log Aggregation
Question 41
Collecting and aggregating
An application that makes it easier to view log files from an IIS web server
1483
Question 42 Distributed cache: A data cache that is distributed over numerous
computer systems but functions as a single entity
Question:
Solution:
c = int(input('Enter third side: ')) analyzing an event that occurs when a visitor to your
s = (a + b + c) / 2 website performs an action
print(s)
Question 43
Question:
Given a list of numbers, Iterate it and print only those numbers which are divisible
of 2.
Solution:
1484
Question 44
Question:
Solution:
import numpy
list = [1, 2, 3] In-database analytics: Data analytics is integrated
result = numpy.prod(list) into the data warehouse operation
print(result)
Question 45
Question:
1485
Question 46
Question:
Solution:
Question 47
Question:
1486
Solution:
Question 48
Question:
1487
Solution:
# Define a dictionary
customers = {'1':'Mehzabin Afroze','2':'Md. Ali',
'3':'Mosarof Ahmed','4':'Mila Hasan', '5':'Yaqub Ali'}
Question 49 Multiplexing:
Solution:
1488
# Define the number set
numbers = {23, 90, 56, 78, 12, 34, 67}
Low code development No-code development
platform platform
# Add a new data
A software development A software development
numbers.add(50)
platform that enables platform that enables
# Print the set values
developers to create new developers to create new
print(numbers)
business applications visually business applications visually
and with little coding without writing a single line
message = "Number is not found"
of code
print(message)
Question 50
Question:
Metadata repository
Solution:
# Try block
A software tool designed to store and share metadata
try:
1489
# Take a number
number = int(input("Enter a number: "))
if number % 2 == 0:
print("Number is even") Statistical power
else: (The power of a hypothesis test)
print("Number is odd")
Question 51
Solution:
1490
print("You are not authenticated")
Question 52
Question:
Solution:
Question 53
Question:
1491
Solution:
Question 54
Manual testing:
Solution:
1492
Question 55
Question:
Write a program to take in the marks of 5 subjects and display the grade.
Solution:
The percentage difference between the experimental and theoretical values goes to zero − if we repeat the
same experiment a large number of times
1493
Question 56 General Availability
Solution:
Question 57
Question:
Write a program to read two numbers and print their quotient and remainder.
1494
b=int(input("Enter the second number: "))
quotient=a//b File server: A computer that stores and manages data
remainder=a%b files so that they can be accessed by other computers
print("Quotient is:",quotient) on the same network
print("Remainder is:",remainder)
Question 58
Question:
Write a program to accept three distinct digits and print all possible combinations
from the digits.
Solution: Upstream
1495
Question 59
Question: Escalate: Take a disputed matter to a higher level of management for settlement
Solution:
Security Remediation:
Question:
Solution:
1496
n=int(input("Enter an integer:"))
Encapsulation
a=[]
(Information hiding)
for i in range(2,n+1):
if(n%i==0):
a.append(i)
a.sort() Methods
print("Smallest divisor is:",a[0])
Class
Variables
Question:
Solution:
Virtualization Emulation
Hardware can be accessed directly We need a software connector to access hardware
1497
Question 62 Exception: An abnormal condition that occurs during the
execution of a software program that causes the normal flow of
the program's instructions to be disrupted
Question:
Write a program to read a number n and print and compute the series
"1+2+…+n=".
Solution:
print()
Output:
Enter a number: 4 # entered number
1 + 2 + 3 + 4 = 10
Write a program to read a number n and print the natural numbers summation
pattern.
1498
Solution:
print()
Output:
Question 64 1 + 2 = 3
1 + 2 + 3 = 6
1 + 2 + 3 + 4 = 10
Question:
Write a program to read a number n and print an identity matrix of the desired
size.
1499
for j in range(0,n):
if(i==j):
print("1",sep=" ",end=" ")
else:
print("0",sep=" ",end=" ")
print()
Question 65
Question:
Write a program to read a number n and print an inverted star pattern of the
desired size.
Solution:
Applied Intelligence
1500
Question 66
Question:
Solution:
print()
Question 67
Question:
Solution:
1501
Operational effectiveness: The plan of action
a=[]
n=int(input("Enter number of elements:")) that a company puts in place in order to arrive at
for i in range(1,n+1):
a better final product or service
b=int(input("Enter element:"))
a.append(b)
a.sort()
print("Largest element is:",a[n-1])
Question 68
Question:
Solution:
a=[]
n=int(input("Enter number of elements:"))
for i in range(1,n+1):
b=int(input("Enter element:"))
a.append(b)
a.sort()
print("Second largest element is:",a[n-2])
1502
Question 69 Appropriateness Recognizability: The extent to which users can
Question:
Write a program to put the even and odd elements in a list into two different lists.
Solution:
a=[]
n=int(input("Enter number of elements:"))
for i in range(1,n+1):
b=int(input("Enter element:"))
Hyperautomation
a.append(b)
even=[]
odd=[] (Robotic Process Automation + ML + AI)
for j in a:
if(j%2==0): The organizations use to rapidly automate
even.append(j)
complex business and IT processes
else:
odd.append(j)
print("The even list",even)
print("The odd list",odd)
Question 70
Question:
Write a program to sort the list according to the second element in the sublist.
1503
Solution:
a=[['A',34],['B',21],['C',26]]
for i in range(0,len(a)):
for j in range(0,len(a)-i-1): SnowBall: A data transport service
if(a[j][1]>a[j+1][1]):
that allows us to move terabytes of
temp=a[j]
data both inside and outside of the
a[j]=a[j+1]
AWS cloud
a[j+1]=temp
print(a)
Output:
Question 71
Question:
Write a program to find the second largest number in a list using bubble sort.
a=[]
Geo-Targeting: A method for advertisers
n=int(input("Enter number of elements:"))
to define geographical location where
for i in range(1,n+1):
their advertising should appear
b=int(input("Enter element:"))
a.append(b)
for i in range(0,len(a)):
for j in range(0,len(a)-i-1):
1504
if(a[j]>a[j+1]):
temp=a[j]
a[j]=a[j+1] # Output:
a[j+1]=temp
print('Second largest number is:',a[n-2]) Enter number of elements:4 # entered number
Question:
Solution: # Output:
Pair Testing
Software testing practice in which 2 individuals test the same feature at the same time on the
same computer by continuously interchanging ideas and feedback
1505
Conversational AI
Question 73
(Natural Language Processing + ML)
Write a program to create a list of Tuples with the first element as the number and
Solution:
Conversational UI: A user interface
that enables computers to interact with
l_range=int(input("Enter the lower range:")) humans using voice or text
u_range=int(input("Enter the upper range:"))
a=[(x,x**2) for x in range(l_range,u_range+1)]
print(a)
# Output:
[(2, 4), (3, 9), (4, 16), (5, 25), (6, 36)]
Question:
Write a program to create a list of all numbers in a range which are perfect
squares and the sum of the digits of the number is less than 10.
Solution:
1506
l=int(input("Enter lower range: "))
u=int(input("Enter upper range: "))
a=[]
a=[x for x in range(l,u+1) if (int(x**0.5))**2==x and sum(list(map(int,str(x))))<10]
print(a)
# Output:
Question:
Write a Program to check whether the given number is valid mobile number or
not.
Solution:
import re
num=input("Enter a mobile number:")
x=re.fullmatch("[7-9]\d{9}",num)
if x!= None: Conversion Attribution
print("mobile number is valid")
A method of determining the channel
else:
through which a user entered a
print("mobile number is not valid")
website or application and carried
out the desired action
Connection String:
1507
Cognitive Automation: Robotic Process Automation
Question 76
Automating repetitive manual
The process of extracting information from unstructured
tasks like data entry
Question: data and deriving meaningful conclusion
Question 77
Question:
Write a Program to check whether the given mail id is valid Gmail id or not.
Solution:
1508
import re
x=input("Enter your Gmail address:")
i=re.fullmatch("\w[a-zA-Z0-9_.]*@gmail[.]com", x)
if i!=None:
print("A valid email address");
else:
print("A invalid email address")
# Output:
x = -2
Question 78 while x < 0:
print(x)
x = x + 1
Question: print('Python!')
Solution:
print(b'Python \xE2\x9C\x85'.decode("utf-8"))
# Output: Python ✓
a = 6
b = 0
print(a >= 2 and b != 0 and (a/b) > 2)
# Output: False
1509
Churn Prediction Model
Question 79
predicts
Solution:
a=[]
n= int(input("Enter the number of elements in list:"))
for x in range(0,n):
element=int(input("Enter element" + str(x+1) + ":"))
a.append(element)
b = set()
unique = []
Brain-computer interface: Technology
for x in a:
if x not in b: that sends and receives signals between the
unique.append(x) human brain and a computer
b.add(x)
print("Non-duplicate items:")
print(unique)
# Output:
Non-duplicate items:
[5, 4, 2]
1510
Question 80 (Digital Transformation + Design strategy)
Write a program to take input from the user until they type alan.
Solution:
while True:
x = input('>> ')
if x == 'alan':
break
print(x)
print('Done!')
Output:
Comparing the way machine and human brain works and creating
machines that perform task or think like humans
1511
Question 81
Question:
Write a program to only count digits that are either 0 or 2 in a positive integer
Solution:
x = 2896510
i = 0
while x > 0:
a = x % 10
if a == 0 or a == 2:
i = i + 1
x = x // 10
print(i)
Hard error: An error that corrupts system files Handheld device: Any portable computing
and causes a failure of an operating system without device that can be carried and held in one's hand
providing any recovery options
i = 0
while i < 3:
Hook: A location in a software program where an
print(f"index {i}")
instruction for performing a certain function is inserted i = i+1
i = 0 # Output:
while True: index 0
print(f"index {i}") index 1
if i > 2: index 2
break Output:
i= i + 1 Net Promoter Score
index 0
index 1 An evaluation of customer satisfaction and loyalty that
index 2 is based on a 0 –10 scale that asks clients whether they
index 3 would suggest your goods or services to others
1512
Question 82
Question:
Solution:
# Output: 3 6 9 12 15
1513
print("Hi", "Alan Turing", sep="---")
x = 0
while True:
i = input("\n Enter a number: ")
if i == "0" or i == "-1":
break
x = x + int(i)
print("The sum of the numbers you entered is: ", x)
# Output:
Enter a number: 2 # entered number
Enter a number: 3 # entered number
Enter a number: 0 # entered number
The sum of the numbers you entered is: 5
2 + 3 + 0 = 5
Hung terminal
Immediate access storage: A storage
If the previous work session is still visible on the device that houses all of the data and
display screen but the terminal does not respond programs that the CPU is currently using
to keyboard input, it is termed 'hung'
13
# Output:
19
39
Done!
1514
Hand off: Get rid of an unwanted task
Question 83
Question:
Solution:
# Output: False
• If data is being put onto the server, it's inbound transfer Information appliance:
• If data is being requested from the server, it's outbound transfer
1515
x = "Alan"
print("O" + x[1:])
# Output: Olan
Question:
Solution:
import time
1516
Question 85 x=["albert einstein", 6, ["1905", "1915", "Papers"], [4, 5, 8]]
print(x[2])
# Output: ['1905', '1915', 'Papers']
Question:
Output:
Solution:
0
for i in range(21): 4
if i % 4 == 0: 8
print(i) 12
16
20
4 # Output: 2.0
print ("Albert", 5 + 3 / 2)
# Output: Albert 6.5
x = {} Output:
print ("What is 2 + 16?", 2 + 16)
for i in "Ala": 4
# Output: What is 2 + 16? 18
print(x.get(i, 4)) 4
4
print("Is it greater?", 15 >13)
# Output: Is it greater? True
1517
x = False
y = "Is -5 greater than 3? %r"
print(y % x)
# Output: Is -5 greater than 3? False
x = 'Albert'
y = 'Einstein'
print(x+y) # Output: AlbertEinstein
print(x, y) # Output: Albert Einstein
Wild duck: An individual who is creative and technical and does unusual things
Question 86
x = "%r %r %r"
print(x % (11, 12, 13)) # Output: 11 12 13
Question: print(x % ("A", "B", "C")) # Output: 'A' 'B' 'C'
Write a program to compute simple interest given all the required values.
Solution:
1518
Nice to have: It's a good idea, but it's not required
Question 87
print(list(range(3, 0, -1)))
# Output: [3, 2, 1]
Question:
Solution:
x=int(input("Enter a year:"))
if(x%4==0 and x%100!=0 or x%400==0): Workaround: Making something
print("The year is a leap year!")
operate despite the problem without
else:
completely solving it
print("The year isn't a leap year!")
Question:
Write a program to print out all the positions in a list where it finds negative numbers.
1519
Predictive Analytics
(What will happen?)
# python program to print out the reciprocal of each number in the list
Solution:
Output:
x=int(input("Enter a number: "))
Enter a number: 4
print("All divisors of", x, "are:")
All divisors of 4 are:
for i in range(1,x+1):
1
if(x%i==0):
2
print(i)
4
1520
Question 90
print("Main(\\return)")
# Output: Main(\return)
Question:
a=int(input("Enter a number:"))
for i in range(1,11):
Protocol analyzer: A hardware or software tool that allows recording
print(a,"x",i,"=",a*i)
of network traffic and analyzing it in order to detect network traffic
issues or suspected fraudulent activity
Omnichannel Retailing:
Question 91
The process through which many platforms are combined
and used to impact a customer's decision to buy
Question:
1521
print("The number is an Armstrong number. ")
else:
print("The number isn't an Armstrong number. ")
Output:
Write a program to print the real and imaginary parts of a complex number.
Solution:
a = (5+10j)
print(a.real)
# Output: 5.0
print(a.imag)
# Output: 10.0
1522
Self-service business intelligence
Question 93
A methodology of data analytics that makes it possible for business consumers to
connect and use business data even if they lack experience with business
print("The number is a Perfect number!") # Output: [21, 22, '1905 Papers', 23, 24]
else:
print("The number is not a Perfect number!")
i = 'A B C D'
print(i.split(' ', 1))
p = "~a ^ (b % c)"
# Output: ['A', 'B C D']
i = p.maketrans("~^()", "!&[]")
print(i.split(' ', 2))
Question 94 # Output: ['A', 'B', 'C D']
print(p.translate(i))
# Output:!a & [b % c]
print(i.split(' ', 3))
# Output: ['A', 'B', 'C', 'D']
Question:
1523
Solution:
a = "www.snapdeal.com"
print(a.strip("w"))
# Output: .snapdeal.com
Question 95 print(a.strip("com"))
# Output: www.snapdeal.
print(a.strip(".wmoc"))
Question: # Output: snapdeal
Solution:
print("alan".replace("a", "+*&"))
import math
# Output: +*&l+*&n
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
print("The GCD of the two numbers is", math.gcd(a,b))
1524
a = [2, 4, 6, 8]
b = []
a = [2, 4, 6, 8]
for i in a:
Question 96 b.append(i * i)
b = [i * i for i in a]
print(b)
print(b)
Question:
# Output: [4, 16, 36, 64]
# Output: [4, 16, 36, 64]
Solution:
# Output:
import os Print out which directory
The Albert: ['Einsteinian', 1915, 'Papers']
print(os.getcwd()) we are currently in
C:\Users\Manju print(a)
# Output:
{0: 'zero', 11: 'Eleven', 12: 'Twelve'}
1525
Big Data Visualization: The graphical representation of
Question 97
big data to give the individual the capability to understand
Solution:
if x%i==0:
sum1+=i 2 numbers are said to be "Amicable numbers" if each is
if y%j==0:
sum2+=j
if(sum1==y and sum2==x): Streaming analytics:
print( x, 'and', y, 'are Amicable numbers')
else: The processing and analysis of data from
print(x, 'and', y, 'are not Amicable numbers')
sources
# Output:
Enter a number: 220 # entered number
Enter a number: 284 # entered number
that continuously sends data
220 and 284 are Amicable numbers
Voice Assistant:
The digital assistant that uses
to perform a variety of actions after hearing a wake word or command from the end user
1526
Question 98 a = [0] a = [0]
b = [a, 1] b = [a, 1]
print(a is b[0]) print(a == b[0])
Question: # Output: True # Output: True
Write a program to find the area of a triangle given all three sides.
import math
a=int(input("Enter first side: "))
b=int(input("Enter second side: "))
c=int(input("Enter third side: "))
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("Area of the triangle is: ",round(area,2))
Theoretical probability:
For example:
Experimental probability:
When a coin is tossed:
1
• P (head) = Number of times event occurs
2 P (event) =
Total number of trails
1
• P (tail) =
2 For example:
When a coin is tossed 7 times: A head is recorded 5 times and a tail 2 times
5
• P (head) =
7
2
• P (tail) =
7
# prints a list of names of all the files present in the current directory
import os
print(os.listdir(os.curdir))
1527
print(r"Alan" == "Alan")
Write a program to find the gravitational force acting between two masses.
Solution:
Question 100 A foreground service → Performs some operation that the user is aware of
A background service → Performs some operation that the user is unaware of
Question:
x = 'alanalbertjohn'
y = x.maketrans('ab', '26')
print(x)
# Output: alanalbertjohn
print(x.translate(y))
# Output: 2l2n2l6ertjohn
1528
import re
print(re.compile(r"\\alan")) x= 0
# Output: re.compile('\\\\alan') if x % 2 == 0 :
if x == 0 :
print ("x is even but zero" )
def myfunc(x= "Albert" ):
else :
print (x)
print ("x is even" )
myfunc()
else :
# Output: Albert print ("x is odd" )
Question 101
Question:
Suppose we have a text with three numbers in it. Write a program to filter these out
Solution:
import re
x = '''
Prince Albert died on 14 December 1861 Output:
at the age of 42
['14', '1861', '42']
'''
print (re.findall( r'\d{1,4}' , x))
Cohort analysis: A kind of behavioral analytics where users are grouped based
on shared characteristics to help us better monitor and analyze their activity
1529
import re
x = '''
Prince Albert died on 14 December 1861 # Output:
at the age of 42
''' Prince Albert died on 76 December
print (re.sub( r'\d{1,4}', "76" , x)) 76
at the age of 76
Yield management
Question 102
A marketing approach that focuses on reaching the right
customer at the right moment and at the right price
Question:
# Output:
Solution:
[[[8 8 8]
import numpy as np [8 8 8]
print (np.full(( 2 , 4 , 3 ), 8 )) [8 8 8]
[8 8 8]]
[[8 8 8]
import numpy as np
[8 8 8]
print (np.linspace( 0 , 50 , 5))
[8 8 8]
# Output: [ 0. 12.5 25. 37.5 50. ]
[8 8 8]]]
print(np.arange( 1 , 10 , 3 ))
# Output: [1 4 7]
import numpy as np
a = 2
First In, First Out: A data structure processing print(np.exp(a))
method in which the first element is handled first # Output: 7.38905609893065
and the newest element is handled last print(np.log(a))
# Output: 0.6931471805599453
1530
Question 103
x= 4
**** # Output:
**** 1 2 3 4
1 2 3 4
****
1 2 3 4
1 2 3 4
x= 4
Solution:
for i in range(1,x+1):
print("* "*x) x= 4
for i in range(1,x+1):
for j in range(1,x+1):
Solution: x= 4
for i in range(1,x+1):
for j in range(1,x+1):
print(i, end=" ")
print()
1531
x= 4 x= 4
for i in range(1,x+1): for i in range(1,x+1):
for j in range(1,x+1): for j in range(1,x+1):
print(chr(64+j),end=" ") print(x+1-i, end=" ")
print() print()
# Output: # Output:
A B C D 4 4 4 4
A B C D 3 3 3 3
A B C D 2 2 2 2
A B C D 1 1 1 1
x= 4 x= 4
for i in range(1,x+1): for i in range(1,x+1):
for j in range(1,x+1): for j in range(1,x+1):
print(x+1-j, end=" ") print(chr(65+x-i),end=" ")
print() print()
# Output: # Output:
4 3 2 1 D D D D
4 3 2 1 C C C C
4 3 2 1 B B B B
4 3 2 1 A A A A
x= 4
# Output:
for i in range(1,x+1):
D C B A
for j in range(1,x+1):
D C B A
print(chr(65+x-j),end=" ") D C B A
D C B A
print()
1532
x= 4 x= 4
for i in range(1,x+1): for i in range(1,x+1):
for j in range(1,x+2-i): for j in range(1,x+2-i):
print("*",end=" ") print(i, end=" ")
print() print()
# Output: # Output:
* * * * 1 1 1 1
* * * 2 2 2
* * 3 3
* 4
x= 4 x= 4
for i in range(1,x+1): for i in range(1,x+1):
for j in range(1,x+2-i): for j in range(1,x+2-i):
print(j, end=" ") print(chr(64+i),end=" ")
print() print()
# Output: # Output:
1 2 3 4 A A A A
1 2 3 B B B
1 2 C C
1 D
x= 4
for i in range(1,x+1): # Output:
for j in range(1,x+2-i): A B C D
print(chr(64+j),end=" ") A B C
A B
print() A
1533
x= 4
x= 4
for i in range(1,x+1):
for i in range(1,x+1):
print(" "*(x-i),"*"*i, end=" ")
print(" "*(x-i),end="")
print()
for j in range(1,i+1):
print("*",end=" ")
# Output:
print()
*
**
# Output:
***
*
****
* *
* * *
* * * *
x= 4
for i in range(1,x+1):
print(" "*(x-i),(str(i)+" ")*i) x= 4
2 2
# Output:
3 3 3 1
1 2 3
4 4 4 4 1 2 3 4 5
1 2 3 4 5 6 7
x= 4
for i in range(1,x+1): # Output:
print(" "*(x-i),end="") 1
for j in range(2*i-1,0,-1): 3 2 1
print(j, end=" ") 5 4 3 2 1
print() 7 6 5 4 3 2 1
1534
Question 104
print(str(6) == '6')
# Output: True
Question:
Solution:
Question:
Write a program to find the sum of series: 1 + 1/2 + 1/3 + ….. + 1/N.
1535
Question 106 print([(a, b) for a in range(2) for b in range(2)])
# Output:
[(0, 0), (0, 1), (1, 0), (1, 1)]
Question:
Solution:
def myfunc(x):
if x <= 0:
return False
else:
return x & (x - 1) == 0
if myfunc(x):
Question 107
Question:
Solution:
1536
x=input("Enter a string: ")
x=x.replace('a','$') # Output:
print(x) $l$n
Question 108
2 strings are said to be anagrams if they have the same characters
but are arranged differently. For example: "keep", "peek"
Question:
Solution:
# Output:
x=input("Enter the first string: \n")
Enter the first string:
y=input("Enter the second string: \n") keep # entered string
if(sorted(x)==sorted(y)): Enter the second string:
print("The 2 strings are anagrams.") peek # entered string
else:
The 2 strings are anagrams.
print("The 2 strings aren't anagrams.")
# prints the names of the employees whose salaries are above 20000
i = [a for a, b in salary if b>20000]
print(i)
1537
Question 109
Question:
Write a program to modify a string where the first character and the last character
Solution:
def myfunc(x):
return x[-1:] + x[1:-1] + x[:1] # Output:
x=input("Enter a string: ") Enter a string: james # entered string
print("Modified string: ") Modified string:
print(myfunc(x)) samej
Question 110
Question:
Solution:
1538
x=input("Enter a string:")
v=0
for i in x:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
v=v+1
print("Number of vowels: ")
print(v)
# Output:
Enter a string: albert # entered string
Number of vowels:
2
Question 111
Question:
Write a program to take a string and replace every blank space with a Plus symbol.
Solution:
# Output:
x=input("Enter a string: ")
x=x.replace(' ','+')
Enter a string: alan turing # entered string
print("Modified string: ")
Modified string:
print(x)
alan+turing
1539
# contents of 1.txt
print([line.strip() for line in open("1.txt")])
John
# Output: ['John', 'Mary', 'James', 'Albert']
Mary
James
Albert
Question 112
Question:
Write a program to calculate the length of a string without using library function.
Solution:
print(x[6:3:-1]) # Output: aM
print(x[4:8:2]) # Output: a
1540
x = ['Albert Einstein was a theoretical physicist.',
'Albert Einstein grew up in Munich.',
'One of the greatest physicists of all time.']
print(list(a))
# Output:
print(list(a))
# Output:
1541
Question 113
Question:
Solution:
# Output:
word=1 2
character=character+1 11
if(i==' '):
word=word+1
print("Number of words in the string:")
print(word)
print("Number of characters in the string:")
print(character)
# Output:
[[2.9, 2.8, 2.5], [3.5, 3.4, 3.2], [4.4, 4.9, 4.0]]
1542
x = '''
Python is a high-level, interpreted,
general-purpose programming language.
Its design philosophy emphasizes code
readability with the use of significant indentation
'''
print(find(x, 'the'))
x = '''
Python is a high-level, interpreted,
general-purpose programming language.
Its design philosophy emphasizes code
readability with the use of significant indentation
'''
print(find(x, 'the'))
1543
Question 114
Question:
Solution:
x=input("Enter a string:")
c=0 Enter a string: Alan
Question 115
Question:
Write a program to count the number of lowercase letters and uppercase letters
in a string.
Solution:
1544
x=input("Enter a string: ")
c=0
d=0
for i in x:
if(i.islower()):
c=c+1
elif(i.isupper()):
d=d+1
print("The number of lowercase characters: ")
print(c)
print("The number of uppercase characters: ")
print(d)
import numpy as np
Question 116 x = np.array([31, 32, 33, 34], dtype=np.int16)
print(x) # Output: [31 32 33 34]
Question:
print(x.dtype) # Output: int16
Solution:
1545
import numpy as np
import numpy as np
x = np.array([2] * 4)
print(x) import numpy as np
1546
Question 117
Question:
x={'A':1,'B':2}
y={'C':3}
x.update(y)
print(x)
# Output: {'A': 1, 'B': 2, 'C': 3}
Question 118
Question:
x={'A':1,'B':2,'C':3}
key=input("Enter a key to check: ")
if key in x.keys():
print("Key is present and value of the key is:")
print(x[key]) # Output:
else: Enter a key to check: A
print("Key isn't present!") Key is present and value of the key is:
1
1547
Question 119
Question:
x={'A':100,'B':540,'C':239}
print("The sum of values in the dictionary: ")
print(sum(x.values()))
# Output:
The sum of values in the dictionary:
879
x = 3
Question 120
fact = lambda x: x * fact(x-1) if x > 1 else 1
print(fact(x))
x={'A':10,'B':10,'C':10}
# Output:
a=1
The product of values in the dictionary:
for i in x:
1000
a=a*x[i]
print("The product of values in the dictionary: ")
print(a)
1548
Unsorted array
10 6 8 2 5 4 9 1
Unsorted array indices
0 1 2 3 4 5 6 7
Sorting algorithm
sort()
argsort()
Sorted array
1 2 4 5 6 8 9 10
Sorted array indices
7 6 5 4 3 2 1 0
import numpy as np
x = np.array([10, 6, 8, 2, 5, 4, 9, 1])
print(np.sort(x))
# Output: [ 1 2 4 5 6 8 9 10]
print(np.argsort(x))
# Output: [7 3 5 4 1 2 6 0]
import re
x = 'Albert Einstein profoundly changed physics and ideas about space and time'
print(re.findall('p.*?c.*?s', x))
1549
import re
x = 'Albert Einstein profoundly changed physics and ideas about space and time'
print(re.findall('a.d', x))
# Output: ['and', 'and']
import re
x = 'Albert Einstein profoundly changed physics and ideas about space and time'
print(re.findall('A.*n', x))
# Output:
['Albert Einstein profoundly changed physics and ideas about space an']
import re
print(re.findall('a{2,4}b', 'ab')) from sympy import sqrt
# Output: [] print(sqrt(16))
print(re.findall('a{2,4}b', 'aaab')) # Output: 4
# Output: ['aaab']
print(re.findall('a{2,4}b', 'aaaaab'))
# Output: ['aaaab']
print(re.findall('a{2,4}b', 'aaaaaab'))
# Output: ['aaaab']
import re
x = 'Albert profoundly changed physics and ideas about space and time'
print(re.sub("Albert(?!')", 'Einstein', x))
# Output:
Einstein profoundly changed physics and ideas about space and time
print(is_anagram("peek", "keep"))
# Output: True
1550
# check whether a given number x is prime or not
def myfunc(x):
for i in range(2,x):
import sympy
if x % i == 0:
print(sympy.isprime(178))
# Output: True
print(myfunc(178))
# Output: False
# Output: [2, 3, 5, 7]
print(Float('1.44E5')) # Output: 5
print(Float(1.55555,2)) # Output: 0
# Output: 1.6
1551
import sympy x = set('abc')
print(x)
# prints the SymPy version
# Output: {'b', 'a', 'c'}
print(sympy.__version__)
x = {'a', 'b', 'c'}
print(x)
from sympy import FiniteSet
# Output: {'b', 'a', 'c'}
x=[1,3,5,2,8]
y=[12,10,8,7,1]
from sympy import FiniteSet, Complement
print(FiniteSet(*x))
x=[1,3,5,2,8]
# Output: {1, 2, 3, 5, 8}
y=[12,10,8,7,1]
print(FiniteSet(*y))
a=FiniteSet(*x)
# Output: {1, 7, 8, 10, 12}
print(a)
# Output: {1, 2, 3, 5, 8}
from sympy import FiniteSet
b=FiniteSet(*y)
x="alan"
# Output: {1, 7, 8, 10, 12}
y="jonny"
print(b)
print(FiniteSet(*x))
print(Complement(a,b), Complement(b,a))
# Output: {a, l, n}
# Output: {2, 3, 5} {7, 10, 12}
print(FiniteSet(*y))
# Output: {j, n, o, y}
1552
for i in ['Alan', 'Albert', 'James', 'John']:
print('Mary ' + i)
x = 'Alan'
# Output: y = 'Albert'
Mary John
if not 'd' in x:
print('%e' % x)
print('Missing!') # Output: 3.333333e-01
# Output: Missing! print('%4.2f' % x)
# Output: 0.33
print(x.get('a')) # Output: 4
print('{0:4.2f}'.format(x))
# Output: 0.33
print(x['d'] if 'd' in x else 'Missing!')
# Output: Missing!
1553
import decimal
decimal.getcontext().prec = 3
print(decimal.Decimal('2.00') / decimal.Decimal('6.00'))
# Output: 0.333
decimal.getcontext().prec = 2
print(decimal.Decimal('2.00') / decimal.Decimal('6.00'))
# Output: 0.33
x = 'David'
print(x[:5] + 'Hilbert' + x[-1])
# Output: DavidHilbertd
i = 5.987654321
print('%e | %f | %g' % (i, i, i))
# Output: 5.987654e+00 | 5.987654 | 5.98765
1554
Question 121
Question:
# Output:
Enter a string: alan alan is # entered string
{'alan': 2, 'is': 1}
Question 122 for ((x, y), z) in [([21, 22], 23), ['AB', 26]]: print(x, y, z)
# Output:
Question:
21 22 23
A B 26
1555
Question 123
Question:
Write a program to display which letters are in the first string but not in the
second string.
a=list(set(x)|set(y))
for i in a:
print(i)
1556
M = {}
M[(12, 13, 14)] = 78
M[(17, 18, 19)] = 64
X = 12; Y = 13; Z = 14
print(M[(X, Y, Z)])
# Output: 78
print(M)
# Output: {(12, 13, 14): 78, (17, 18, 19): 64}
if (12,13,16) in M:
print(M[(12,13,16)])
else:
print('Missing!')
# Output: Missing!
x = {'name': 'John',
'courses': ['python', 'java'],
'email': '[email protected]',
'address': {'state': 'Canada', 'zip':54600}}
print(x['name']) # Output: John
print(x['courses']) # Output: ['python', 'java']
print(x['courses'][1]) # Output: java
1557
x = [11, ('i', 13)]
y = [11, ('i', 12)]
print(x < y, x == y, x > y)
# Output: False False True
x = '1988'
y= 'max'
x = {'p':11, 'q':12}
print(x.isdigit(), y.isdigit())
y = {'p':11, 'q':13}
# Output: True False
print(x == y)
# Output: False
while True:
x = input('Enter a string: ')
if x == 'END': break
print(x.lower())
# Output:
Enter a string: Alan # entered string
Enter a string: END # entered string
end
x = 'ALAN'
a, b, c, d = x
print(a, d) # Output: A N
a, b, c = list(x[:2]) + [x[2:]]
print(a, b, c) # Output: A L AN
1558
while True:
x = 'ALAN'
x = input('Enter a number: ') a, b = x[:2]
if x == 'end': break c = x[2:]
print(int(x) ** 2) print(a,b,c)
print('Have a Good Day!') # Output: A L AN
(a, b), c = x[:2], x[2:]
while True:
x = input('Enter a number: ') # Output:
while True:
x = input('Enter a number: ') # Output:
if x == 'end': break
try: Enter a number: 5
25
i = int(x)
Enter a number: max
except:
Wrong Entry Wrong Entry
print('Wrong Entry ' * 2)
Enter a number: end
else:
Have a Good Day!
print(int(x) ** 2)
print('Have a Good Day!')
1559
while True:
x = input('Enter a number: ')
# Output:
if x == 'end': break
elif not x.isdigit(): Enter a number: 5
Enter a number > 25
print('Wrong Entry ' * 2)
else: Enter a number: 36
1296
i = int(x)
if i < 25: Enter a number: max
Wrong Entry Wrong Entry
print('Enter a number > 25')
else: Enter a number: end
Have a Good Day!
print(i ** 2)
print('Have a Good Day!')
Question 125
Question:
if __name__ == '__main__':
birthdays = {
'Albert Einstein': '03/14/1879',
'Benjamin Franklin': '01/17/1706',
'Ada Lovelace': '12/10/1815',
'Donald Trump': '06/14/1946',
'Rowan Atkinson': '01/6/1955'}
1560
# Output:
11 [12, 13, 14]
12 [13, 14]
13 [14]
14 []
# Solution:
x = [11, 12, 13, 14] x = [11, 12, 13, 14]
while x: while x:
Or
i, x = x[0], x[1:] i, *x = x
print(i, x) print(i, x)
import sys
1561
x=0; y=5
while x < y:
print(x, end=' ')
x += 1
# Output: 0 1 2 3 4
i = 'apple'
while i:
print(i, end=' ')
i = i[1:]
while True:
x = input('Enter a string: ')
if x == 'einstein': break
y = input('Enter a number: ')
print(x, '=>', int(y) ** 2)
# Output:
Enter a string: alan # entered string
Enter a number: 5 # entered number
alan => 25
Enter a string: einstein # entered string
# Output: [0, 2, 4]
# Output: a b r
1562
# Output:
import numpy as np
plt.show()
import numpy as np
plt.show()
# Output:
Indians
Arabs
Germans
Americans
x = [1, 2, 3, 4]
[11, 2, 3, 4]
for s in range(len(x)): [11, 12, 3, 4]
x[s] += 10 [11, 12, 13, 4]
print(x) [11, 12, 13, 14]
1563
x = [1,2,3,4]
print([i + 10 for i in x])
# Output:
15 25 ... 40
16 26 ... 42
17 27 ... 44
18 28 ... 46
John
Mary
Contents of 1.txt
James
Albert
1564
import matplotlib.pyplot as plt
import numpy as np
a = np.array([2,4,5,9,11,6,8,15])
b = np.array([92,94,95,99,101,96,98,115])
plt.scatter(a, b)
plt.show()
# Output:
140
120
100
80
60
40
20
0
0 2 4 6 8 10 12 14 16
import pandas as pd
x= pd.DataFrame({
'names': ['Alan', 'John', 'James', 'Albert'], names ID
print(pd.concat([x,y]))
1565
print(list(filter((lambda i: i < 0), range(-4, 4))))
Question 126
# Output: [-4, -3, -2, -1]
print(list(filter((lambda i: i > 0), range(-4, 4))))
Question: # Output: [1, 2, 3]
# define punctuation
i = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
# Output:
for s in x: Enter a string: Alan: Turing! # entered string
if s not in i: Alan Turing
y = y + s
print(list(range(-4, 4)))
# Output: [-4, -3, -2, -1, 0, 1, 2, 3]
y, z = 11, 2
def myfunc():
ab = []
global x
for i in range(-4, 4):
x = y * z
if i > 0:
print(x)
ab.append(i)
print(ab)
myfunc()
# Output: 22 # Output: [1, 2, 3]
1566
Question 127
Question:
import socket
x = socket.gethostname()
y = socket.gethostbyname(x)
print("My Computer Name is: " + x)
print("My Computer IP Address is: " + y)
# Output:
My Computer Name is: DESKTOP-68GI94H
My Computer IP Address is: 192.168.6.1
import random
minimum = 1
maximum = 6
x = "yes"
Python program to
while x == "yes" or x == "y": illustrate Dice
print ("Rolling the dice...") Roll Simulator
print ("The value is....")
print (random.randint(minimum, maximum))
1567
import re
print('{0:,d}'.format(5000000))
# Output: 5,000,000
print('{0:12,.2f}'.format(5000000))
# Output: 5,000,000.00
# Output: Users/Manju/1.txt
# Output: Users/Manju/1.txt
# Output: Users/Manju/1.txt
1568
from datetime import date, timedelta
# Output: 2022-11-16
# Output: 2022-10-21
x = OrderedDict()
x['alan'] = 1
salary = {
x['Alex'] = 2
'Alan': 24000,
x['john'] = 3
'Albert': 5000,
x['mary'] = 4
'Mary': 2000,
for i in x:
}
print(i, x[i])
print(min(zip(salary.values(), salary.keys())))
# Output:
# Output: (2000, 'Mary')
alan 1
print(max(zip(salary.values(), salary.keys())))
Alex 2
# Output: (24000, 'Alan')
john 3
mary 4
import json
print(json.dumps(x))
1569
x = { x = 'data.csv'
'a' : 11, print(x[-4:] == '.csv')
'c' : 13
} x = 'https://www.wikipedia.org'
y = { # Output: True
'd' : 10,
'a' : 11,
x = {'a': 1, 'c': 5 }
'b' : 12
y = {'b': 2, 'd': 4 }
}
# Output: {'c'}
import re
print(re.split(r'[;,\s]\s*', x))
1570
import re
x = 'https://www.wikipedia.org'
print(re.match('http:|https:|ftp:', x))
print(fnmatch('1.csv', '*.csv'))
# Output: True
print(fnmatch('data.txt', '?ata.txt'))
# Output: True
print(fnmatch('file1.txt', 'file[0-9]*'))
# Output: True
print(x=='Albert')
# Output: False
print(x.startswith('Albert'))
# Output: True
print(x.endswith('st'))
# Output: True
print(x.find('or'))
# Output: 30
1571
x = '12/29/1992'
import re
if re.match(r'\d+/\d+/\d+', x):
print('Albert')
# Output: Albert
else:
print('Alan')
if re.match(r'\d+/\d+/\d+', y):
print('Einstein')
# Output: Turing
else:
print('Turing')
import re
print(re.compile(r'\d+/\d+/\d+').findall(x))
import re
̃o
print('Acya\u0303o') # Output: Acya
1572
import re
print(re.findall('einstein', x, flags=re.IGNORECASE))
x = 'Albert' x = 987654321
English mathematician,
theoretical biologist.
1573
x = '''Alan Mathison Turing was an
import textwrap
print(textwrap.fill(x, 50))
# Output:
print(sum([1.23e+18, 1, -1.23e+18]))
# Output: 0.0
Alan Mathison Turing was an English
biologist.
biologist.
1574
import numpy as np
from fractions import Fraction
for i in np.arange(0, 4, 0.5): print(i)
x = Fraction(7, 2)
0.0
y = Fraction(9, 18)
0.5
z = x * y
1.0
print(z) # Output: 7/4 1.5
Output
print(z.numerator) # Output: 7 2.0
3.0
3.5
import numpy as np
print(np.matrix([[11,-22,23],[0,54,65],[87,98,-19]]))
print(os.path.getsize('C:/Users/Manju/1.txt'))
[ 0 54 65]
print(time.ctime(os.path.getmtime('C:/Users/Manju/1.txt')))
[ 87 98 -19]]
25
import numpy as np
Fri Jul 8 04:53:18 2022
for i in np.arange(0, 1, 0.125): print(i)
# Output:
0.5 # Output:
0.625
14 13 12 11
0.75
0.875
1575
x = ['A', 'B', 'D']
x = ['A', 'B', 'D']
from itertools import permutations
from itertools import permutations
for i in permutations(x, 3):
for i in permutations(x, 2):
print(i)
print(i)
# Output:
# Output:
('A', 'B', 'D')
('A', 'B')
('A', 'D', 'B')
('A', 'D')
('B', 'A', 'D')
('B', 'A')
('B', 'D', 'A')
('B', 'D')
('D', 'A', 'B')
('D', 'A')
('D', 'B', 'A')
('D', 'B')
print(i)
# Output:
('A', 'D')
('B', 'D')
John = 89
1576
print('Papers', 1905, 1915)
# Output: Papers,1905,1915
# Output: Papers,1905,1915!!
import io
print(io.StringIO().write('Albert'))
# Output: 6
print(io.StringIO().write('Alan'))
# Output: 4
print(io.StringIO().write('Joe'))
# Output: 3
import tempfile
# Output: Albe
print(tempfile.gettempdir())
print(io.StringIO('Albert').read())
# Output: Albert
C:\Users\Manju\AppData\Local\Temp\tmp3d75il4w
print(tempfile.mkdtemp())
1577
Last-In, First-Out: A data structure processing method in which the newest
element is handled first and the first element is handled last
probability of success
Odds =
probability of failure
probability of success
Logit Function = log ( )
probability of failure
𝟏𝟓 𝟏𝟓 𝟏𝟎 𝟏𝟎
Entropy = − log2 ( )− log2 ( ) ≈ 0.97
𝟐𝟓 𝟐𝟓 𝟐𝟓 𝟐𝟓
a = 'AlbertEinstein1905Papers'
print(a[:3] + a[3:])
# Output: AlbertEinstein1905Papers
1578
Prior probability
Does not require compilation before The geometry of the data is utilized to make the
execution algorithms more efficient
A/B testing
(Split testing or bucket testing)
A method of comparing 2 versions of a web application against each other to figure out
which one is more effective
which one performs better
Data in motion: Any digital information that is being moved over a network from
Data at rest: Any digital information that is not being moved over a network from
1579
In-memory database: Database that depends primarily on memory for data storage
In-memory processing: Processing of data stored in an in-memory database
In-memory computing: Running computer calculations entirely in computer memory
Design
Develop
Review
Finalize
Publish
1580
Serial correlation: A pattern in which each value is influenced
directly by the value next to it or preceding it in a sequence
Machine learning
Learning-to-Learn
GIGO
(Garbage In, Garbage Out)
Request-Response Model
HTTP
Request
HTTP
Response
1581
a = {1,2,3,4,5,6}
b = {5,6,7,8,9}
Python code to print the common
x,y=2,3
print("Alan") if x>y else print("Turing")
# Output: Turing
print('EINSTEIN'.isupper())
print('einstein'.islower()) Output on the screen:
True
True
1582
Jenkins Pipeline:
Ruby Program:
a = 26
unless a>=25
end
Student Student
1583
Dialog Management Systems (DMS):
Cold Migration: The method of transferring a virtual machine that is shut down, together
with its configuration and data, from one host to other
Hot Migration: The method of transferring a virtual machine that is powered on, together
with its configuration and data, from one host to other
Negative Evidence:
Non-linearity:
1584
Prospective Data Analysis:
Programming Assistant:
If 2 sets have no elements in common, they are
said to be disjoint. For example: {2, 4, 5} and
A programming framework that assists a
{6, 7, 9} are disjoint sets, while {2, 4, 5} and
programmer to handle the non-clerical
{1, 5, 8} are not disjoint.
aspects of programming
Negative response
Mandatory entry field: A field in which a user must enter at least one character
Run time:
Run-time environment → Execution environment
The length of time that a
computer program is running
Network congestion: An undesirable overload
condition arises when a network is unable to
Nit: A minor flaw that can be
appropriately handle the traffic pouring through it
easily corrected
1585
Iterative server:
Background processes:
Mapping: The process of transforming data
Processes that run without the
transmitted in one format by the sender into a
intervention of a user
format that the receiver can understand
# Output: 9
Data science approach:
1586
Size of Test
(The probability of committing a type I error)
Power of Test
Data Literacy
1587
Dependent Data Mart Independent data mart
constructed with the use of a central data constructed without the use of a central data
warehouse warehouse
Monolithic kernel: An operating system framework in which the entire operating system runs in kernel space
Microkernel: A small piece of software capable of providing the processes required to implement an operating system
Autoencoder: A type of artificial neural network with the A kind of data model that displays a
number of output units in the output layer is equal to the unified perspective of all data used by
number of input units in the input layer the enterprise firm
BLEU
1588
Cloud Enablement: The process of creating, deploying and operating
"the existing infrastructure, resources and services that a enterprise is currently using on-premises"
on the cloud
CAPTCHA
(Completely Automated Public Turing Test to tell Computers and Humans Apart)
Overheating
DataOps
(Data Operations)
1589
Reverse ETL: A method of feeding data from a
Pivot table: A powerful tool for rearranging
data warehouse that has been cleansed and
huge lists of data, as well as summarizing
processed back into business applications for
and analyzing them
operations and forecasting
Given a weight survey data, weights of participants ranging from 50.0 to 60.0 are
grouped together in one bucket, 60.1 to 70.0 in another, and so on.
print({1,3,5}=={1,2,3}) True
False
1590
Go Program:
Ruby program:
package main
$x = 1
import "fmt"
$y = 4
Output:
func main() { while $x < $y do
puts("#$x") 1
fmt.Println(" ", 10 + 11)
$x = $x +1 2
} end
3
# Output: 21
# Output:
1591
SCD
(Slowly Changing Dimensions)
The process for generating, maintaining, A platform that combines services and technologies to
and sending test data to application store, manage and analyze data to address the needs of
development teams large data-driven enterprise organizations
If we use height, weight and sweet intake to forecast the probability of Diabetes mellitus:
If we throw a coin, there are only two possible outcomes: head or tail
If a test is taken, there are only two possible outcomes: either pass or fail
1592
Markov chain or Markov process: A stochastic model that predicts the
probability of a particular event based on previous events
Digital Twin: A software program that Dynamic model: A model that is trained
generates stimulation that precisely online with the constantly updated data
replicates a physical object based on
real-world data in order to predict how
a physical object would behave
Data downtime:
Data Joining: Combining the data from different tables within the same data source
Data fabric: An architectural design that allows access to data regardless of its location
Stress testing
1593
Distributed Database:
Database
Network Database
Database
Database
Self-documenting code
1594
Symmetric Encryption Asymmetric Encryption
One key can be used for both encryption and decryption To encrypt and decode data, two keys are required
Used by
Training data ML Algorithm
Results in
ML Model
Routing analysis
Transactional data: The
unpredictably changing data
A kind of network analysis that discovers the most efficient path gathered during transactions
between two or more network locations
1595
The revenue generated by selling the
products and services
NewSQL
A database language that combines and builds on the concepts and principles of both SQL and NoSQL
SQL injection: A hacking technique that uses malicious SQL code to steal information from your database
1596
Go program:
package main
import "fmt"
Output:
A data mining technique used by retailers to identify purchases that commonly happen together.
For example, customers who purchase pencil and rubber also purchase sharpener and scale. Or
customers who purchase shoes might also purchase socks.
func main() {
Atomicity
for {
1597
Cache
Web browsers use a cache to store web pages so that the user may view them
Request
Response
Data buffer
A region of a memory used to temporarily store data while it is being moved from one place to another
Computer cracker
Crash
An event wherein the operating system or a computer application stops functioning properly
1598
Streaming
Directory
Watching any video content or
listening to audio content that is A folder where all files are kept on a computer
Firewall
HTTP HTTPS
HTTPS
Multimedia
A Software program that combines text and graphics with sound, video and animation
Freeware: software that anyone can download from the Internet and use for free.
1599
Platform
(SSL)
Encryption-based Internet
security protocol that allows
Internet users to send encrypted
User Normal HTTP messages across the Internet
Insecure connection
SEO
HTTP + SSL = HTTPS
(search engine optimization)
Wi-Fi
Wired Equivalent Privacy (WEP)
Wireless technology used to connect
A security protocol for Wi-Fi networks computers, tablets, smartphones and
other devices to the internet via a
Add security to Wi-Fi networks by encrypting data
wireless signal
Wi-Fi Protected Access (WPA): security protocol designed to create secure wireless (Wi-Fi) networks. It provides better data
encryption and user authentication than Wired Equivalent Privacy (WEP)
1600
DNS → Domain Name Service
HTTP → Hyper Text Transfer Protocol
SMTP → Simple Mail Transfer Protocol Post office protocol (POP)
POP → Post Office Protocol
FTP → File Transfer Protocol
Message request protocol in the Internet world that provides e-mail client (receiver) the ability
to fetch and receive email from an e-mail server
SMTP
POP3
SMTP
SMTP
Cloud migration
Application logic runs on user's computer Application logic runs in the cloud
1601
Data migration
The process of moving data from one storage system or computing environment to another
Data
Cloud Migration
Cloud portability
The ability to move applications and its associated data from one cloud
Cloud interoperability
The ability of the systems to work efficiently and collaborate effectively across different cloud platforms
Data orchestration
{Organize the data → Transform the data → Make the data available to the tools that need it}
The process of bringing data together from multiple data storage locations − combining and
organizing it − and preparing it for data analysis
1602
ETL ELT
ETL:
Staging area
{Processing server}
ELT:
ETL does not transfer raw data into the data warehouse
ELT sends raw data directly to the data warehouse
Automation Orchestration
Setting up one task to run on its own Automating many tasks together
{automating one task} {automation not of a single task but an entire IT-driven process}
1603
Infrastructure as a service (IaaS): Renting servers, virtual machines, storage, networks and operating systems
Platform as a service (PaaS): Supplying an on-demand environment for developing, testing, delivering and managing software applications
Storing the same piece of data more than once in the database A way to get to know data
before working with it
Data Presentation
Data cleaning
The process of correcting and deleting inaccurate records from a database or table
Data integration
The process of bringing data from different sources together to provide users with a unified view
Null: a character with no value or missing value. If $a= " " and $b= "1", $a possess a null value.
1604
Logical reasoning
Generalization
Collect the information
Procedure Function
The practice of tracking and
A block of code that is called to A block of code that is called to perform a task managing changes to software
perform a task and will return one or more values
code
Usability testing
Plan the test → Recruit the desired number of testers → Prepare → Set up testing environment → Conduct the test → Analyze data → Report results
1605
MEAN Stack MongoDB + Express.js + Angular.js + Node.js
Pair programming
2 developers use just one machine to work − meaning they work simultaneously on
a single block of code. Person who writes code is called a driver and a person who
observes and checks each line of the code is called navigator.
Command line
Object oriented programming
A text interface that takes in commands and passes
on to the computer's operating system to run. Polymorphism
Inheritance
Encapsulation and abstraction
Object-oriented database
+
Relational database
MVC
Integrity [the overall accuracy, completeness and reliability of data]
[Model-View-Controller]
Concurrency [the ability of the database to support multiple users]
Query processing
1. data (model)
The practice of protecting systems, network data and
2. user-interface (view)
programs from unauthorized access
3. application logic (controller)
1606
Grayware Hypervisor
Hyperlink A crucial piece of software that
makes virtualization possible
A piece of text that when clicked
Malicious software that is not as
destructive as a virus − but can worsen takes the user to a webpage
the performance of computer and cause Software that creates and
A Windows service that allows several computers to share one Internet connection on a local area network
IP address
Renting of network services to customers who don't want to build their own networking infrastructure
Nameserver
1607
Network adapter → A device that connects our computer to a network
SAN (storage area network) → A network of data storage devices
An interface for transferring data between a computer's motherboard and storage devices
virtual hosting
1608
Compression → A technique that reduces file size
Software bug → An error or flaw in a computer program
Word processor → A software that allows users to create, edit and print documents
Modem → A hardware device that is used to transfer information between computers via a phone line
The process of generating an image from the The ability of a program to process human
information contained in a file by means of a speech into a readable text
computer program.
A graphics-based operating system interface that enables a person to communicate with a computer
by using icons, menus and a mouse (to click on the icon or pull down the menus)
Attributes
For example: if the file has a read-only attribute − the file cannot be modified and can only be read
Meta tags
Pieces of information that tell the search engine more about your webpage and the information it contains
1609
Plugin
Redirect
A piece of software that gives the
Automatic forward to a
browser additional functionality
different URL from the one
If we want to watch a video on a website, we may need a
we originally requested
plugin to do so. If the plugin is not installed, our browser
will not understand how to play the video.
A web development approach that makes our web content adapt A blueprint of our website that help
to the different screen sizes and viewports. search engines find, crawl and index
our entire website's content.
Data Bus
The connection between the CPU and RAM – literally a collection of electrical wires − used to send information between CPU and RAM
Fetch instruction
Embedded testing
1610
Anti-malware software
Hardening
Software Patch
A modification to a program to resolve functionality issues − improve security and performance − and add new features
Root access
Penetration test
An authorized simulated cyber attack on a computer system to evaluate the security of the system
1611
Sensitive information
Data that must be protected from unauthorized access to safeguard the privacy and security of an organization
Data Synchronization
Computer worm
The integration of data between 2 or more devices
A malicious malware that reproduces itself
and spreads over network connections
Implementation model
Interaction Diagram
1612
Software Architecture Software Design
Recursive self-improvement
making self-improvements
Technological singularity
A condition that could arrive in the near future where technological growth
A piece of software that installs The first piece of code that is executed
files such as applications, drivers when the computer system is started and
Code refactoring
1613
Evolutionary Computation
Heuristics
Ambiguity
Human-level hardware
Human-level software
Software that matches the Human brain's algorithmic efficiency for performing the
Computing overhang
1614
Hardware overhang
A situation where large amounts of hardware being used for other purposes
Intelligence explosion
Development Testing
Acceptance
1615
Adversarial Machine Learning
Black Box Attack: The attacker has no knowledge of the machine learning model
Grey Box Attack: The attacker has partial knowledge of the machine learning model
White Box Attack: The attacker has complete knowledge of the machine learning model
Data sanitization
The process of intentionally, permanently and irreversibly deleting or destroying the data
stored on a memory device − to ensure it cannot be recovered
Data corruption
Adversarial Example
1616
Artificial Superintelligence
Artificial General Intelligence
Custom Training
Facial recognition
The method of identifying or verifying the identity of a person using their face
1617
Number of false positives
False positive rate =
Number of false positives+ Number of true negatives
Feature Extraction
The transformation of raw data into the inputs that a particular Machine
Feature selection
from the raw data and removing the irrelevant or less important information
The model performs well on the training data but does not perform accurately on the test data
1618
Data augmentation
Cross-validation
Regularization
Ensembling
A technique that combines two or more machine learning models to produce one best predictive model
The error we get on the same data with which The error we get on a unknown data
1619
Bias
The difference between the prediction of the values by the Machine learning model and the actual value
Variance
Machine learning model with high variance will have the adjustability to match any dataset that is provided to it
A specialized electronic circuit designed to render graphics for display on an electronic device
Image Recognition
Optical character recognition: The ability of software to identify the text inside
1620
Autonomous
Machines make their own decisions and potentially take their own actions to solve a
problem − without needing human intervention
We have a decision and based on the We have some data and we make a
Decision Data
Data Decision
Big data
Corpus
A large collection of text and speech data that can be used to train AI and
1621
Entity annotation
Entity extraction
A branch of artificial intelligence that is concerned with giving computer program the ability to
understand text and speech in much the same way humans can
1622
Predictive analytics
A branch of statistics that deals with extracting information from data and
Sentiment analysis
or neutral emotions
Image Segmentation
ImageNet
1623
Reactive machines
The most basic functionality of AI where the machine can only react to the
input it receives − with no ability to use its past experience or previous data
to make decisions
Limited Memory
The ability of AI to store previous data and use it to make better predictions
Theory of mind
The ability of AI to understand human thoughts and emotions and use this to build
Self-awareness
1624
Reinforcement Learning
A type of memory in a computer that allows A type of memory in a computer that allows
storing data temporarily storing data permanently
(Highly accurate and used for prediction) (Less accurate and used for analysis)
Transfer learning: Learning of a new tasks relying on the previous learned tasks
1625
AI Assurance
Explainability Interpretability
The process of explaining why and how a machine The extent to which a human can understand the
learning model made a decision cause of a decision made by machine learning model
Commonsense Reasoning
Visual recognition
Visual Search
1626
Object Detection
an image or video
Object Tracking
Zero-shot learning
One-shot learning
On-premises Software
1627
Number of true positives A measure of how often a
Precision = model predicts something is
Number of true positives+ Number of false positives
true when it is actually true
Number of true positives + Number of false positives > Number of true positives
Number of true positives + Number of false positives < Number of true positives
Search Query
A list of phrases and keywords users enter in search engines to find information about things of interest
Selective Filtering
1628
Student452A | Alan
Database Firewalls
stored in the databases from malware attacks, data loss and thievery
Augmented intelligence
than replacing it
1629
Edge computing
Deepfake
The AI based technique of creating fake images and videos that we cannot
Deployed AI
1630
F1-score
Bayes Theorem:
P(E|H) • P(H)
P (H | E) =
P(E)
Binarization
Data discretization
The method of converting a large number of data values into smaller ones so that
assessment and management of data becomes unchallenging
1631
Build-Measure-Learn cycle
(BML cycle)
Ideas
Learn
Build
Data Product
Measure
Recommendation system
1632
Data Preparation Process
Serialization
Deserialization
Rule-Based Approach
1633
Number of true positives
Precision =
Number of true positives + Number of false positives
Deduction:
Induction:
AI winter
reduced funding for researches and low interest from the people
1634
C → Consistency A → Availability P → Partition Tolerance
All users see the same data at System continues to function System continues to function even if
the same time even with node failures the communication fails between nodes
CAP Theorem: A distributed database system can only support 2 out of these 3 properties:
Consistency, Availability, and Partition Tolerance
Centralized Database
✓ ✓
Structured data → Rules of Inference → Conclusion
× ×
Unstructured data → Rules of Inference → Conclusion
✓ ✓
Unstructured data Structured data → Rules of Inference → Conclusion
1635
Social Network Analytics:
PLAN
ACT
REFLECT
What happened?
LEARN
1636
Dynamic Data: Data that change often Machine learning as a service
Static Data: Data that does not change
Providing ML tools as a part of cloud computing services
Simpson's Paradox:
A huge storage of business information for
A>C the purpose of reporting and analysis
B>D
Data mart: The access layer of a data warehouse used
to provide information to users
But A + B < C+ D
PDSA
Binary Variable
Plan-Do-Study-Act
Evaluation Metrics: A set of metrics used to evaluate the quality and performance of a ML model.
Examples of evaluation metrics are:
Number of true positives
Recall =
Number of true positives + Number of false negatives
Number of true positives
Precision =
Number of true positives + Number of false positives
Number of true positives +Number of true negatives
Accuracy = Number of true positives + Number of true negatives + Number of false positives +Number of false negatives
2 × Precision × Recall
F-measure =
Precision + Recall
1637
Decision-Tree:
Yes No
Yes No
1 2 3 + 4 5 6
A B
5 7 9
(A + B)
import numpy as np
Output on the screen:
A = np.array([1, 2, 3])
B = np.array([4, 5, 6]) [5 7 9]
print(A + B)
1638
1 2 3 × 4 5 6
A B
4 10 18
(A × B)
import numpy as np
Output on the screen:
A = np.array([1, 2, 3])
print(A * B)
2 × 4 5 6
A B
8 10 12
(A × B)
import numpy as np
Output on the screen:
A = np.array([2])
print(A * B)
1639
Code:
import numpy as np
B = A.copy() [1 2 3]
print(B)
Code:
import numpy as np
B = A.view() [1 2 3]
print(B)
Code:
import numpy as np
A = np.array([1, 2, 3])
Output on the screen:
A[0] = 6
[6 2 3]
B = A.view()
print(B)
Code:
import numpy as np
A = np.array([1, 2, 3])
Output on the screen:
A[1] = 6
B = A.view() [1 6 3]
print(B)
1640
Code:
import numpy as np
A = np.array([1, 2, 3])
Output on the screen:
A[1] = 6
B = A.copy() [1 6 3]
print(B)
Code:
System.out.println(a.equals(b));
Code:
1641
Feature selection:
Set of all features → Selecting the best feature → ML Algorithm → Model performance
Hold-out method
Imputation:
Name Age
Alan 21
Incomplete data: The second row contains a missing value
Stephen
Albert 25
Name Age
Alan 21 Complete data: The missing value is filled with mean of all ages
21+ 25
Stephen 23 i.e. = 23
2
Albert 25
1642
A metric used to assess the
TP → Number of true positives
performance of a
classification model
TN → Number of true negatives
FP → Number of false positives
Matthews Correlation Coefficient (MCC): FN → Number of false negatives
TP × TN –FP × FN
MCC =
√(TP+FP)(TP+FN)(TN+FP)(TN+FN)
−1 indicates total disagreement between predicted values and actual values (inverse prediction)
0 indicates average random prediction (completely random guessing)
1 indicates total agreement between predicted values and actual values (perfect prediction)
Hello, World!
1643
Code:
System.out.println(str[1].length());
x = "100"
def myfunc():
print(x)
Global variable declaration
myfunc()
def myfunc():
x = "100"
myfunc()
1644
Name Height Weight
Confounder
Pareto principle:
80% of results are produced by 20% of causes
Examples include:
20% of convicts commit 80% of offences
20% of bus drivers cause 80% of all road accidents
1645
Append Extend
x = [1,2,3,4,5,6] x = [1,2,3,4,5,6]
x.append(7) y = [7]
print (x) x.extend(y)
print (x)
[1, 2, 3, 4, 5, 6, 7] [1, 2, 3, 4, 5, 6, 7]
Python Code:
Python Code:
x = ['Stephen', 'William']
x.extend('Hawking')
print (x)
1646
Bias and variance → prediction errors of a ML model
1
Bias ∝
variance
Low bias and Low variance → The goal of any supervised ML algorithm to achieve strong prediction performance
Therefore, a balance is maintained between the bias and variance and this is called the bias-variance trade-off
Python code:
Positive correlation
High scores on A are associated with High scores on B If we want to study the diabetes among the
Low scores on A are associated with Low scores on B people in South Africa and we study 500
people then those 500 became sample
Negative correlation whereas the all the people in the South
High scores on A are associated with Low scores on B African country is the population
1647
Python code:
print(list(set(x+y)))
Python code:
print(list(set(x+y)))
Empirical Rule:
(68–95–99.7 Rule)
68% of the observations in a normal distribution lie within (mean ± standard deviation)
95% of the observations in a normal distribution lie within (mean ± 2 × standard deviation)
99.7% of the observations in a normal distribution lie within (mean ± 3 ×standard deviation)
Fuzzy Matching
1648
Confusion matrix
A table which contains information about predicted and actual values of a classification problem − used
for evaluating the performance of a classification model
True Positive: The actual value is positive and the model predicts a positive value
True Negative: The actual value is negative and the model predicts a negative value
False Positive (Type 1 error): The actual value is negative but the model predicts a positive value
False Negative (Type 2 error): The actual value is positive but the model predicts a negative value
Python code:
import numpy as np
Output on the screen:
A = np.array([[2, 4, 8], [5, 7, 1]]) [[ 8 20 48]
print(A * B)
1649
# Python code to convert uppercase string to lowercase
str = 'ALBERT'
print(str.lower())
print(5//2)
print(5/2)
Output on the screen:
2
2.5
1650
Degree of fit
Divide and conquer technique
Subproblem Subproblem
Solution to Solution to
Subproblem Subproblem
Solution to problem
∑
A metric for comparing observed results
(Observed –Expected)2
Chi squared = with expected results
Expected
1651
Selection Sort
3 4 1 5 2 Array to be sorted
Sorting at index 0
3 4 1 5 2
Sorting at index 2
1652
Sorting at index 3
1 2 3 5 4
1 2 3 4 5
hi
Alan
Alan
Alan
Alan
hi
Alan
hi
1653
find . -mtime -1 -type f -print0 | xargs -0 tar rvf "12.tar"
# Backup each file or directory that have been modified within the last 24 hour
Insertion Sort
1 2 8 10 17 6 Array to be sorted
1 2 8 10 17 6 17 > 6, swap
1 2 8 10 6 17 10 > 6, swap
1 2 8 6 10 17 8 > 6, swap
1 2 6 8 10 17
1654
[manju@localhost ~]$ for i in 1 2 3 4 5 ; do echo "$i" ; done
1655
[manju@localhost ~]$ for i in `seq 1 6`;do echo $i ;done
[manju@localhost ~]$ cat 2.txt [manju@localhost ~]$ cat 2.txt | while read LINE; do echo "${LINE}"; done
Hi Hi
Alan
Alan
John
John
1656
Linux command: ss -tunlp4
Description: Find only the files (but not directories) modified in the last 40 minutes
Parameter Statistic
Statistical significance
1657
Alternative Data
[manju@localhost ~]$ ls
[manju@localhost ~]$ ls
22
1658
Standard score
If Z-Score = 0:
Observed value = Mean of the sample
Alpha value
p value
which implies:
1659
Greedy Algorithmic Approach:
Find the largest number that can be formed with the given digits:
8 3 7 4
Find the smallest number that can be formed with the given digits:
8 3 7 4
8 3 7 4
Largest number → 8743 (The arrangement of the given digits in descending order)
Smallest number → 3478 (The arrangement of the given digits in ascending order)
1660
Distributive Property:
De Morgan's Laws:
X × (Y + Z) = XY + XZ
not (X or Y) = not X and not Y
If X = {1, 2} and Y = {3, 5, 7}, then the Cartesian Product of X and Y is {(1, 3), (1, 5), (1, 7), (2, 3), (2, 5), (2, 7)}
1661
Akaike information criterion:
L = likelihood function
k = number of parameters to be estimated
n = number of observations (sample size)
(not-x)
(not not-x)
(x and y)
1662
Exclusive Or x⊕ y x ⊕ y is true only if exactly one of x and y is
not both)
(42 < 0) → (2 < 4) is true because (42 < 0) is false and (2 < 4) is true
(2 < 4) → (42 < 0) is false because (2< 4) is true and (42 < 0) is false
Text: "Einstein was the greatest physicist of the twentieth century. Einstein was German"
Tokenization: Breaking
Sentence 1: Einstein was the greatest physicist of the twentieth century
the text into sentences
Sentence 2: Einstein was German
A bag of words
1663
Kolmogorov's 3 Axioms of Probability Every Data Scientist Should Know:
Axiom 1:
0 ≤ P(A) ≤ 1
Axiom 2:
Possible outcomes are head or tail Possible outcomes are the numbers 1, 2, 3, 4, 5, and 6
Axiom 3:
If P(A ∩ B) = 0:
1664
R-Squared:
Adjusted R-Squared:
The technique for grouping The technique for finding the frequently
Pre-Pruning Post-Pruning
Stop the growth of the decision tree before it Stop the growth of the decision tree after it
completely classifies the training set completely classifies the training set
1665
Blue-green deployment: A methodology for deploying software upgrades that minimizes
downtime by managing active traffic between 2 identical production environments
Box diagram:
Modify the structure of the database Query or modify the data of the database
Bandwidth:
The maximum amount of information that can be sent from one point to another
1666
Over 95% of Linux is written in C language
[manju@localhost ~]$ for ((x=0,y=50; x<=5; x++,y-=1)); do printf "x=%03d y=%03d\n" $x $y; done
x=000 y=050
x=001 y=049
x=002 y=048
x=003 y=047
x=004 y=046
x=005 y=045
[manju@localhost ~]$ ls
[manju@localhost ~]$ ls *
1.txt abc.cpp abc.txt ab.txt bc.pdf BC.txt CD.txt io.txt log txt
Desktop:
Documents:
Downloads:
Music:
Pictures:
Public:
Templates:
Videos:
1667
[manju@localhost ~]$ ls .*
.:
..:
manju users
.cache:
abrt gstreamer-1.0
event-sound-cache.tdb.localhost.localdomain.x86_64-redhat-linux-gnu imsettings
evolution tracker
gdm webkit
gnome-shell
.config:
.local:
Share
.mozilla:
extensions plugins
1668
[manju@localhost ~]$ ls
abc.txt
d41d8cd98f00b204e9800998ecf8427e abc.cpp
d41d8cd98f00b204e9800998ecf8427e ab.cpp
d41d8cd98f00b204e9800998ecf8427e abc.txt
d41d8cd98f00b204e9800998ecf8427e ab.pdf
d41d8cd98f00b204e9800998ecf8427e ab.txt
d41d8cd98f00b204e9800998ecf8427e bc.pdf
d41d8cd98f00b204e9800998ecf8427e bc.txt
[manju@localhost ~]$ wc -l /etc/hosts || echo "The command wc -l /etc/hosts failed to read /etc/hosts"
2 /etc/hosts
[manju@localhost ~]$ names=( Albert Alan John Hawking Stephen Steve Balmer ); echo ${names[@]:0:1}
Albert
[manju@localhost ~]$ names=( Albert Alan John Hawking Stephen Steve Balmer ); echo ${names[@]:1:1}
Alan
[manju@localhost ~]$ names=( Albert Alan John Hawking Stephen Steve Balmer ); echo ${names[@]:2:1}
John
1669
date 00101000
BASH Linux Kernel
ls 10100001
cal 11100000
Linux shell
Binary code
Linux commands
26
15
Thursday
./file2.txt
./FILE.txt
1670
[manju@localhost ~]$ find . \( -name "*.cpp" -o -name "*.txt" \) -print
./.cache/tracker/db-version.txt
./.cache/tracker/db-locale.txt
./.cache/tracker/miner-applications-locale.txt
./.cache/tracker/last-crawl.txt
./.cache/tracker/first-index.txt
./1.txt
./ab.txt
./bc.txt
[manju@localhost ~]$ cat ab.txt
./cd.txt
56
./io.txt
66
./AB.txt
[manju@localhost ~]$ cat ab.txt | echo $[ $(tr '\n' '+' ) 0 ]
./BC.txt
./CD.txt 122
./abc.txt
85
./abc.cpp
./ab.cpp
./files.txt
./file1.txt
./file2.txt
./FILE.txt
./ab.c
./ab.java
./abc.cpp
./ab.cpp
./ab.c
1671
find . -type f -atime -5 -print
# Print all the files that were accessed within the last five days
# Print all the files that have an access time older than 15 minutes
[manju@localhost ~]$ find . -type f -name "*.pdf" -exec printf "PDF FILE: %s\n" {} \;
ALBERT EINSTEIN
54321
45678
Albert Papers [manju@localhost ~]$ echo Albert 1905 Einstein 1921 Alan 1933 | tr -d -c '0-9 \n'
1672
[manju@localhost ~]$ echo albert einstein was a German | sed 's/\w\+/[&]/g'
EINSTEIN albert
Physical Topology
1
Transmission delay ∝ Handshake
Network Bandwidth
1
Propagation delay ∝
Transmission speed
The manufacturer's issued
unique identifier for a piece of
A piece of hardware that controls how data is transferred across a network
network hardware
1673
Selection Bias
The Law of Demeter
Communication between X
and Y is discouraged since Y
is a stranger to X
X Z Y
Communication
between X and Z is
encouraged since Z is a
friend of X
The standard deviation of the sample determines the confidence interval. When outliers are introduced into
the sample, the standard deviation increases, and the confidence interval increases with it
Measurement Bias:
Bias is created when the information gathered isn't totally correct (imprecise)
1674
If a server-side web application contains multiple versions of the same function
Package X Package Z
weight-gain powder
weight gained
With Dependence Inversion Principle
Response variable
Package X Package Z
Object X Object Z
Benchmarking
Object X refers Interface X
1675
Continuous Deployment Continuous Delivery
The deployment to the production environment is The deployment to the production environment is not
completely automated, requiring no human intervention automated, requiring manual or human intervention
Spoofing Traits
The ability of a cloud to expand or contract its The ability of a cloud to scale up or down its
infrastructure resources in response to an infrastructure resources in response to expected
unanticipated or abrupt increase in demand increase in demand
1676
P(6, 2): (6) + (2) ≥ 7
True propositional statement
8≥7
5≥7
Multitasking Multiprocessing
Link or edge: The connectivity between two communicating devices in the network
Node Node
1677
In Microsoft operating systems:
ipconfig
ifconfig
A network-level protocol that is used to convert the IP address to the MAC address
Assists in the
identification of the device
Epoch
The number of times the machine learning algorithm has passed through the entire training dataset
1678
dataset size × number of epochs = number of iterations × batch size
If N = 1:
If N = 2:
If N = 3:
1679
Number of defects rejected
Defect -rejection ratio = × 100
Total number of defects of software
One to One Relationship When a single row in table A is linked to a single row in table B, this type of relationship is used
One to Many Relationship When a single row in table A is linked to many rows in table B, this type of relationship is used
Many to Many Relationship When many rows in table A is linked to many rows in table B, this type of relationship is used
1680
Ruby program:
Output: Output:
The value of a is 42. 0
The sum of a and b is 62. 1
The product of a, b and c is 10920. 2
{Input Layer} {Hidden Layer 1} {Hidden Layer 2} {Hidden Layer 3} … {Hidden Layer N} {Output Layer}
Deep neural networks include multiple hidden layers between the input and output
layers, whereas shallow neural networks have only one hidden layer
1681
Armstrong number:
The sum of the cubes of each digit of 153 is equal to the number itself
The sum of the fourth power of each digit of 1634 is equal to the number itself
Python code:
num = 153
sum = 0
d = num
while d > 0:
digit = d % 10
sum += digit ** 3
d //= 10
if num == sum:
else:
Output:
1682
num = 1634
sum = 0
d = num
while d > 0:
digit = d % 10
sum += digit ** 4
d //= 10
if num == sum:
else:
Output:
1683
print("hello"*3) hellohellohello repetition
print("hello"+"world") helloworld concatenation
print("hello"[0]) h indexing
print("hello"[-1]) o from end
print("hello"[1:4]) ell slicing
print(len("hello")) 5 size
1687
∑ (x̅−xi )2
Standard deviation = √
(n−1)
x̅ : mean
2, 4, 6 and 8
(5 − 2) 2 + (5 − 4) 2 + (5 − 6) 2 + (5− 8) 2 = 20
20
Standard deviation = √(4−1) = √6.66666666667 = 2.5819
Python code:
Output:
print('Alan'.rjust(10))
Alan
print('Mathison'.rjust(20))
Mathison
print('Turing'.ljust(10))
Turing
1688
print('Albert'.rjust(10, '/')) # Output: ////Albert
print(ord("A"))
# Output: 65
print(ord("C"))
# Output: 67
import pyperclip
pyperclip.copy('Alan Turing')
import re
x= re.compile(r'Chat(bot|room|man)')
1689
# Create an iterator 'x' from iterable 'ALAN'
x = iter('ALAN')
while True:
try:
print(next(x))
# When there are no more items, the iterator 'x' raises the StopIteration
except StopIteration:
Output:
import time
year = time.localtime()[0]
month = time.localtime()[1]
date = time.localtime()[2]
print(month) # Output: 7
print(date) # Output: 5
1690
Dead code Unreachable code
Cyclomatic Complexity = E − N + (2 × P)
Start
E = number of edges
N = number of nodes
P = number of nodes that have exit points x = 16
Yes No
y>z
x=y x=z
Dark Launch
Print x, y, z
Lead Time: The length of time from the The above graph shows seven shapes (nodes), seven lines (edges), hence
beginning of a process to its completion Cyclomatic Complexity = 7−7 + (2×1) = 2
1691
Python Code:
try:
print("Try") Output:
print(10/2) Try
except: 5.0
print("Exception") Finally
finally:
print("Finally")
try:
Output:
print("Try")
Try
print(10/0)
Exception
except ZeroDivisionError:
print("Exception") Finally
finally:
print("Finally")
try:
print("Try") Output:
print(10/0)
print(10/0)
except NameError:
ZeroDivisionError: division by zero
print("Exception")
finally:
print("Finally")
1692
import re
x=re.search("^Alan", i)
if x != None:
else:
import re
x=re.search("philosopher$",i)
if x != None:
else:
Application Whitelisting:
1693
import re
x=re.search("Philosopher$", i)
if x != None:
else:
import re
x=re.search("Philosopher$",i, re.IGNORECASE)
if x != None:
else:
Incident Management:
1694
Assignment statement
x=5+3
Expression
Variable name
Assignment operator
x='Albert'
print(x[2]) # Output: b
The string 'Albert' and its indexes
x='James'
J a m e s String
print(x[-1]) # Output: s -5 -4 -3 -2 -1 Negative indexes
print(x[-2]) # Output: e
print(x[-4]) # Output: a
print(len('')) # Output: 0
1695
x = 'Albert Einstein grew up in Munich'
x = 0
y = ''
while x < 2:
i = len(x) - 1
while x < 4:
while i >= 0:
x = x + 1
y = y + x[i]
print(x)
i = i - 1 # Output:
print(y) 1
3
print(x)
4
# Output: Albert Einstein grew up in Munich
x = 0
while x < 2: i = 0
x = x + 1 x = 'Alan'[i]
# Output:
print(x)
Alan
i = i + 1
Alan
# Output:
x = 0
A
y = 'Alan'
l
while x < 4:
a
y = y + y[x]
n
x = x + 1
print(y)
# Output: AlanAlan
1696
if 50 > 25:
if 14 != 14:
print('Albert')
if 12 < 14:
elif 50 > 25:
print('Alan') print('Einstein')
# Output: Einstein
# Output: Alan
if 14 != 14 or 50 > 25:
if 50 > 25 and 12 < 14:
print('Albert')
print('Alan')
# Output: Albert
# Output: Alan
import math
# Output:
x=16
Alan
for i in range(2, int(math.sqrt(x)) + 1):
Alan
print('Alan') Alan
# Output:
print(x)
salary 9900
1697
for x in range(2):
for x in range(2):
print(x)
print(x)
print('Alan')
continue
print('Alan')
# Output:
# Output:
0
Alan 0
1
1
Alan
print(x[1][0]) # Output: 11
# Output: Albert+Einstein!
print(x[1][1]) # Output: 12
def myfunc(x):
# Output:
print('David ' + x)
Albert Einstein
print('Albert Einstein')
David Bowman
myfunc('Bowman')
Stephen Hawking
print('Stephen Hawking')
David Hilbert
myfunc('Hilbert')
Robert Hess
print('Robert Hess')
1698
import itertools
print(itertools.product('XY', repeat=4))
print(list(itertools.product('XY', repeat=2)))
# Output: [('X', 'X'), ('X', 'Y'), ('Y', 'X'), ('Y', 'Y')]
print(list(itertools.product(range(2), repeat=2)))
# Output: [(0, 0), (0, 1), (1, 0), (1, 1)]
print(31 % 6) # Output: 1
x = "alan turing"
print(x.title())
# Output: Alan Turing
print(3 + 4*2) # Output: 11
print((3 + 4) * 2) # Output: 14
# Output:
x = {}
My name is: alan.
x['name'] = 'alan'
My name is changed to: albert.
x['age'] = 35
print(x)
# Output: {'name': 'alan', 'age': 35}
1699
i = '1.txt'
x.write("Albert Einstein\n")
# Output:
Albert Einstein
1.txt
Hans Albert Einstein
def myfunc(x):
myfunc('einstein')
x = int(x)
if x % 2 == 0:
else:
# Output:
1700
import pandas as pd
df = pd.read_csv('1.csv')
print(df.to_string())
i = [0, 'albert', 4]
for i[2] in 'abc': print(i)
# Output:
[0, 'albert', 'a']
[0, 'albert', 'b']
[0, 'albert', 'c']
x= 'Church'
1701
x = {'a':24, 'b':5.89}
x['d'] = 73
print(x)
# Output: {'a': 24, 'b': 5.89, 'd': 73}
myfunc(x, y)
print(x, y)
i = [11, 12, 13, 14]
i[1:3] = [52, 53, 54] # Output: 105 [100, 55]
x = [
a = 15; b = 17
'Albert Einstein'.split(),
c = 18; d = 14
'was a German'.split(),
if a < b or c > d:
'born theoretical physicist'.split(),
print('Alan')
]
print(x, (19, 1, 5)) # Output: Alan
# Output:
1702
for x in 4, 10:
for y in 6, 7, 8, 9:
print(f'{5.1459:{x}.{y}}') import re
x = re.compile(r'stand')
# Output:
if x.match('understand'):
5.1459
print('matched..')
5.1459
else:
5.1459
print('Failed to match..')
5.1459
5.1459
5.1459
5.1459
# Contents of '2.txt '
1 albert 2
# Output: Some lines end in numbers.
2 alan 4
3 albert 4
Output 4 alan 4
5 albert 6
6 albert 6
import pandas as pd
print(x)
1703
# pip install click
import click
def myfunc():
click.echo("Albert Einstein")
if __name__=="__main__":
myfunc()
import shutil
# music.zip is created
shutil.make_archive('music','zip','Music')
# pip install fire
# unzip the file 'music.zip'
import fire
shutil.unpack_archive('music.zip')
def myfunc(x): # prints a list of supported archive formats
# Output:
fire.Fire(myfunc("Turing"))
[('bztar', "bzip2'ed tar-file"), ('gztar', "gzip'ed tar-file"),
# Output: Alan Turing ('tar', 'uncompressed tar file'), ('xztar', "xz'ed tar-file"),
x = list(range(1,5))
y = ["Albert", "Einstein"]
for i in x:
# Output:
1 .... ['Albert']
2 .... ['Albert']
3 .... ['Albert']
4 .... ['Einstein']
1704
import pandas as pd
print(x)
print(y)
# Output:
# prints the size of a list
w 11 import sys
print(sys.getsizeof([11, 12, 13, 14]))
y 13
# Output: 96
dtype: int64
w 11
x -14
y 13
z 16
dtype: int64
import pandas as pd
import numpy as np a o m g
apple 0 1 2 3
x = pd.DataFrame(np.arange(16).reshape((4, 4)),
orange 4 5 6 7
index=['apple', 'orange', 'mango', 'grapes'],
mango 8 9 10 11
columns=['a', 'o', 'm', 'g'])
grapes 12 13 14 15
print(x)
1705
import pandas as pd
import numpy as np
orange 5
index=['apple', 'orange', 'mango', 'grapes'],
mango 9
columns=['a', 'o', 'm', 'g'])
grapes 13
print(x['o'])
Name: o, dtype: int32
print(x[['m', 'a']]) m a
apple 2 0
orange 6 4
mango 10 8
grapes 14 12
print(x[:2])
a o m g
apple 0 1 2 3
orange 4 5 6 7
orange 4 5 6 7
mango 8 9 10 11
grapes 12 13 14 15
1706
import bs4
x = bs4.BeautifulSoup('<h1>Alan', 'html.parser')
y = bs4.BeautifulSoup('<h1>Alan', 'xml')
z = bs4.BeautifulSoup('<h1>Alan', 'lxml')
w = bs4.BeautifulSoup('<h1>Alan', 'html5lib')
print(x, x.is_xml)
print(y, y.is_xml)
<h1>Alan</h1> True
print(z, z.is_xml)
print(w, w.is_xml)
print(bs4.BeautifulSoup('<h1>Alan', 'html.parser').prettify())
# Output:
<h1>
Alan
</h1>
import json
x = {
'name' : 'Alan',
'age' : 45,
'salary' : 54200
}
print(json.dumps(x))
# Output: {"name": "Alan", "age": 45, "salary": 54200}
print(json.dumps(True))
# Output: true
1707
Java Program:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
i.add(x * x);
1708
import java.util.ArrayList;
[manju@localhost ~]$ x=15; echo '$x' = $x
import java.util.LinkedList;
$x = 15
albert einstein
public class MyClass {
planets.add("Earth");
planets.add("Uranus");
planets.add("Jupiter");
planets.add(0,"Mars");
System.out.println(planets);
stars.add("Polaris");
Output:
stars.add(1,"Sirius");
[Mars, Earth, Uranus, Jupiter]
stars.add("Betelgeuse");
[Polaris, Sirius, Betelgeuse]
System.out.println(stars);
[manju@localhost ~]$ echo "11" >> 1.txt; echo "12" >> 1.txt; echo "13" >> 1.txt;
11
12
13
36 #11+12+13=36
1709
import java.util.Scanner;
switch(marks) {
case "85":
System.out.println("Distinction");
break;
[manju@localhost ~]$ echo $[ 11+12+13 ]
case "35":
36
System.out.println("Pass");
break;
case "25":
System.out.println("Fail");
break;
Output:
}
35 # entered number
} Pass
./1.sh
./1.py
./2.py
./3.py
1710
import java.util.Scanner;
String x = "john";
String i = keyboard.next();
out.println(i);
out.println(x);
if (x == i) {
} else {
}
Output:
keyboard.close();
Enter your password: alan # entered password
}
You entered: alan
}
But the password is: john
1711
find . -type f -size +5M
1712
find /usr -type f -size +4G -exec ls -lh {} \; | awk '{ print $9 "|| Size : " $5 }'
int i = x.nextInt(5) + 1;
}
# List only symbolic links
If Random number = 2 or 5
}
Output:
import java.io.File;
Albert Einstein
import java.io.FileNotFoundException;
2 or 5
import java.io.PrintStream;
diskWriter.print ('H');
diskWriter.println('i');
diskWriter.close();
}
Deletes existing 1.txt file on the hard drive.
Creates an empty file named 1.txt.
The print method call inserts the letter H into the 1.txt file.
The println method call adds the letter i into the 1.txt file.
So, after running the code, the 1.txt file contains 2 letters: the letters "H" "i".
1713
import java.util.Scanner;
char x, y, z, w;
x = keyboard.findWithinHorizon(".", 0).charAt(0);
y = keyboard.findWithinHorizon(".", 0).charAt(0);
z = keyboard.findWithinHorizon(".", 0).charAt(0);
w = keyboard.findWithinHorizon(".", 0).charAt(0);
System.out.print(w);
System.out.print(z);
System.out.print(y);
System.out.print(x);
Output:
keyboard.close(); nala
cat /proc/partitions
1714
[manju@localhost ~]$ echo "Albert Einstein." | tr 'a-zA-Z' 'n-za-mN-ZA-M'
Nyoreg Rvafgrva.
Albert Einstein.
for i in {1..5}.txt
do
Creates empty files: 1.txt, 2.txt,
touch $i 3.txt, 4.txt and 5.txt
done
Alan Mathison
uring.
Alan
Turing
1715
[manju@localhost ~]$ echo -e "Math\nison" | awk 'BEGIN{ print "Alan" } { print } END { print "Turing" }'
Alan
Math
ison
Turing
**** 1
f rwx = 4 + 2 + 1 = 7
f rw- = 4 + 2 = 6
f r-- = 4
1716
C Program:
double x = 6 * atan(2.0);
return 0;
#include <stdio.h>
int main() {
return 0;
Python code:
Output:
import numpy as np i:
[[11 12 13]
i = np.array([[11, 12, 13], [14, 15, 16]])
[14 15 16]]
print("i:\n{}".format(i))
1717
import matplotlib.pyplot as plt
import numpy as np
b = np.cos(a)
# The plot function makes a line chart of one array against another
plt.plot(a, b, marker="x")
Output:
Information Architecture:
1718
import pandas as pd
print(pd.DataFrame(x))
Minification:
// Output:
The practice of deleting unneeded or redundant
information without altering how the content is
Name Subject Marks handled by the browser, such as formatting and
2 Albert Maths 73
3 Alan Biology 93
Mobile-first
A design approach that prioritizes the smallest screens and starts the design process with mobile
devices in consideration in order to improve customer experiences
Define and record guidelines for determining whether web content complies with accessibility
standards like the Web Content Accessibility Guidelines (WCAG)
1719
import sys
import pandas as pd
import matplotlib
import numpy as np
import scipy as sp
import IPython
import sklearn
# Output: Python version: 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
1720
Accessibility Object Model:
An accessibility tree for an HTML page can be altered and eventually examined by
programmers using a JavaScript API.
Agglomerative Clustering:
The most popular approach of hierarchical clustering that groups objects into
clusters according on how similar they are
import numpy as np
print("{}".format(np.linspace(-2, 2, 11)))
# Output: [-2. -1.6 -1.2 -0.8 -0.4 0. 0.4 0.8 1.2 1.6 2. ]
np.linspace(-2, 2, 11)
1 2 3 4 5 6 7 8 9 10 11
-2 -1.6 -1.2 -0.8 -0.4 0. 0.4 0.8 1.2 1.6 2.
(ASCII)
A standard collection of codes used consistently to represent characters. There are 128 letters, digits,
punctuation, and symbols over all. A distinct binary string has been assigned to each character.
1721
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 10])
y = np.array([0, 100])
plt.plot(x, y)
Output:
120
100
80
60
40
20
0
0 2 4 6 8 10 12
A tool that allows programmers to save and retrieve various development versions of source code
1722
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 10])
y = np.array([0, 100])
Output:
120
100
80
60
40
20
0
0 2 4 6 8 10 12
Cone of Uncertainty
1723
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 10])
y = np.array([0, 100])
Output:
120
100
80
60
40
20
0
0 2 4 6 8 10 12
1724
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 10])
y = np.array([0, 100])
plt.xlabel("X AXIS")
plt.ylabel("Y AXIS")
Output:
120
100
80
60
Y AXIS
40
20
0
0 2 4 6 8 10 12
X AXIS
Duck Typing
A property of some modern computer languages that allows for dynamic data types
1725
Automatic Semicolon Insertion:
JavaScript does not need the use of a semicolon at the end of a statement, in contrast
to other C-like languages. Instead, the semicolon is optional, and when the JavaScript
interpreter runs the code, it will "sensibly" add them
Bad Neighborhood
A collection of websites that are connected and have bad reputations that
search engines have severely devalued
import numpy as np
z = [0.6, 0, 0, 0]
# Pull the "Indians" wedge 0.6 from the center of the pie
Output:
1726
Africans
Indians
Americans
Germans
A postulate in human-computer interaction that asserts that each application has a certain level of inherent
(FCP)
The period of time it takes for a page to load completely − from the time the request is received until any
content appears on the screen. The content loads more slowly the higher the FCP score
IndexedDB:
1727
Self-supervised learning:
A new area of study that lies in between supervised learning and unsupervised
learning and uses automatically labelled data to eliminate the need for human
annotation. It is a method of machine learning where a ML model teaches
itself to learn one feature of the input from another feature of the input
Sentiment analysis:
Sequence to sequence:
The potential to train a model to translate input sequences from one domain (for example, an
English sentence) to output sequences in another domain (for example a sentence in Hindi)
Albert
Alan
John
James
Mary
Yovan
Hawking
Stephen
1728
[manju@localhost ~]$ awk 'length($1) > 6 {print $0}' names.txt
Hawking
Print all names that are longer than 6 characters
Stephen
Alan
Mary
Albert
James
Print all names that do not have 4 characters
Yovan
Hawking
Stephen
Alan
John
Mary
Shape of a tensor:
1729
[manju@localhost ~]$ awk 'length($1) > 0 {print $1, "has", length($1), "chars"}' names.txt
Silhouette Coefficient:
A statistic used to determine the effectiveness of a clustering method. Its value is between -1 and 1
Similarity learning:
A Sparsity of 18% means that 18% of elements in the vector contain zeros
1730
Spatial-temporal reasoning:
A branch of AI where the ultimate goal is to create a system with the ability to
manipulate objects, navigate through time and space, and solve issues
Stacking:
An ensemble machine learning technique that combines predictions from various effective
machine learning models in the most effective way possible
Strong classifier:
The classifier that is responsible for combining the findings from the weak
classifiers into a single appropriate result
Structural similarity:
The degree to which two or more objects' shapes overlap; the more
overlap there is, the more similar the objects are
The outcome of 2 samplings, the first of A feature that was developed during data
which was taken from the population preparation but was not present in the
and the second from the sample input data at the time of the computation
Topic modeling
1731
[manju@localhost ~]$ cat marks.txt
Albert 95
Alan 65
John 92
James 66
Mary 77
Yovan 98
Hawking 56
Stephen 44
Albert 95
Alan 65
James 66
Mary 77
Yovan 98
An application-specific integrated circuit for neural network machine learning that Google
developed using its own Tensorflow software
Translational invariance:
1732
Trend analysis:
A method used in technical analysis that makes predictions about future changes in
stock prices using trend data that has just been observed
There is already a neural network available for any function that we want to
compute since neural networks have some kind of universality in them
Watson studio:
A data science platform developed by IBM that offers the environment and resources
necessary for us to work with others to solve business challenges using data
compression that lowers the number of regularizing gradient boosting framework for
weights in a network that must be trained the programming languages C++, Java,
Python, R, Julia, Perl, and Scala
[manju@localhost ~]$ ls -l
total 4
1733
[manju@localhost ~]$ ls -l | awk '{print $6 " " $9}'
Jul 1.c
Jul 1.cpp
Jul 1.html
Jul 1.pdf
Albert is a Physicist
Charles is a Biologist
John is a Chemist
Alan is a Mathematician
USA
Great Britain
Germany
Russia
1734
echo "1,2,3,4,5" | awk '{ split($0,x,",");for (i in x) {sum+=x[i]} } END {print sum}'
# Output: 15 (1 + 2 + 3 + 4 + 5)
– Austin Freeman
1735
SAP stands for System Applications and Products in Data Processing. One of the world's top
software developers for business process management, SAP helps companies of all sizes manage their
finances, logistics, human resources, and other business areas.
1. Introduction:
SAP is a market leader in offering ERP (Enterprise Resource and Planning) solutions and
services to enterprises across industries for improved work and data management. In 1972, SAP was
Data Processing. It has developed and grown over time to become one of the two leading
competitors in the ERP software market as well as the leading global provider of client / server business
solutions, for which it is now renowned.
In 180 countries, SAP serves more than 335,000 clients, 80% of whom are small- and medium-sized
businesses, according to its 2016 corporate fact sheet. By assisting in better management of
customer needs and nurturing long-lasting and fruitful customer relationships, SAP is a German
multinational software company whose products enable businesses to track customer and
business interactions. SAP also builds a strong technical support for organizations. One of the basic goals
of all corporate companies is to satisfy their customers, and SAP is particularly well-known for its data
management tools that help them do this.
2. What is SAP?
The technological revolution of today is being led by SAP. SAP, the industry leader in
enterprise application software, supports businesses in overcoming the negative effects of complexity,
creating new chances for innovation and growth, and maintaining a competitive edge. This has helped
SAP rise to the top of the list of the biggest providers of ERP and other enterprise applications.
1736
3. History of SAP
In order to continuously transform the information technology industry, five former IBM employees
founded SAP in 1972 with the goal of developing standard application software for the business
potential of technology and real-time business processes. Since its founding, SAP has released a number
of versions, including SAP R/1, SAP R/2, and SAP R/3. The R in these releases stands for "Real-
Time" data processing. The number 3 in the R/3 stands for three-tier client-server architecture.
4. Features of SAP
5. Technical details
ERP
The essential business operations of a firm are included in SAP ERP. Almost every functional area of a
company activity, including the purchase of products and services, sale and distribution, finance,
management, is supported and integrated by the ERP package. The most recent Enhancement
1737
SAP R/3
It is client / server version of the software and it is 3-tier architecture which includes 3 layers
Presentation Layer: that contains the software components that make up the SAPGUI.
Application Layer: that consists of one or more application servers and a message server.
Data Base layer: that consists of a central database system containing all of the data in the R/3.
SAP R/2
It is a main frame version of software and it is 2-tier architecture in which 3 layers are installed in
2 separate servers.
SAP R/1
It is the first version and it is one-tier architecture in which 3 layers are installed in one server.
PP - Production Planning
MM - Material management
HR - Human resource
1738
7. How is SAP in terms of career growth?
SAP provides a faster career growth whether it is functional or technical area, provided the candidate has
good fundamental knowledge in IT domain and a very sound knowledge of SAP. Certification in SAP
can increase your job prospects. Fortune 500 Firms has implemented SAP R/3 and being
successful because of its process integrations among the different organizational functionalities in real
time data accessing under a single common database. There are various sub-modules of SAP
(such as Material Management (MM), Project System (PS), Sales and Distribution (SD), Advanced
Planner and Optimizer (APO), Quality Management (QM) etc.) and every module in SAP has its own
demand and uniqueness and has opened up new job opportunities to execute on an aggressive acquisition
strategy to fill the technology gaps. Owing to the various advantages, more and more organizations are
moving towards adopting SAP to impact business in an important and far-reaching way.
Algorithms that get their learning from data rather than a mathematical model
Linear Regression:
A regression is a technique for figuring out how one variable "y" and another variable "x" is related.
A linear regression is a method used to represent a linear relationship between the independent
variable "x" and the dependent variable "y" in statistics. In Machine Learning, a Linear
Regression is a supervised machine learning algorithm. When there is a linear relationship between
two variables, the dependent variable's value changes in response to changes in the independent variable's
value (increase or decrease). With the use of the following equation, the relationship can be
mathematically represented as:
y = mx + c
1739
where:
The slope of the regression line "m" shows how much of an impact "x" has on "y".
"c" often known as the y-intercept, is a constant. "y" would be equal to m if "x" = 0.
If both the independent and dependent variables increase, the linear relationship is said to
be positive. The following graph can help you understand it:
y
y
x x
If both the independent and dependent variables decrease, the linear relationship is said to
be negative. The above graph can help you understand it:
1740
Random Forest Algorithm:
Decrease overfitting
Speed up training
Improve model correctness
address issues
1741
PL/SQL Code Block Structure:
[DECLARE]
declaration statements;
[BEGIN]
Defined by the keywords
execution statements;
DECLARE, BEGIN, EXCEPTION,
and END
[EXCEPTION]
exception statements;
END;
Data
Numerical transformation
into Visuals
Graphical interpretation
Human interaction
1742
Data flow diagram System flow chart
Graphical representation of the information system Graphical representation of the information system
by describing the process step-by-step
Natural language
The speech recognition not only can understand the voice but also return answers to questions or other
queries that are being asked.
Represents the basic architecture of the software with Represents the graphical structure of an algorithm
the help of modules
1743
Instruction Register: contains the actual instruction which is currently being executed
by the CPU
The program counter: contains the address of the next instruction to be executed by the
program
Memory
Loses its stored information in a very short time Information remains stored as
(for milliseconds) even when power supply is on long as power supply is on
DOS (Disk Operating System) is an operating system that runs from a hard disk drive
1744
Napier bones
A programming language is like a natural, human language in that it favors certain metaphors, images,
and ways of thinking.
0! = 1
n! = n × (n − 1)! if n > 0
Statement Token
(sentence) (word)
1745
Kernel language Aid the programmer in reasoning and understanding
Variables
local variable
instance variable
static variable
Instance Variable: A variable declared inside the class but outside the body of the method
1746
// syntax error
#include<stdio.h>
int main()
{
int x = 23;
int y = 25;
// run-time error
#include<stdio.h>
int main()
{
int n = 19, div = 0;
// wrong logic
// number is divided by 0,
div = n/0;
1747
// linker error
Occurs when the executable of the program
cannot be generated
#include<stdio.h>
int Main() // Here Main() should be main()
{
int a = 10;
printf("%d", a);
return 0;
}
// semantic error
Occurs when the statements written in the
program are not meaningful to the compiler
#include<stdio.h>
int Main()
{
int a, b, c;
a + b = c; // semantic error
return 0;
}
// logical error
#include<stdio.h>
int main()
{
int i = 0;
1748
for(i = 0; i < 3; i++);
{
printf("loop ");
continue;
}
getchar();
return 0;
}
1 2 3 4 5
11 12 13 14 15
Hash function
1749
Class Object
1750
Plan your program Write code Test code
Find errors
Think of a solution
Debugging Process:
Computer forensics:
1. Identify the error
The process of evaluating the
2. Identify the exact location of the error
3. Understand and analyze the type of bug or error damage produced by a security
4. Checks all the new errors in the program attack and figuring out how
1751
Android - Application Components
Activities
If you open your phone application, you see number of activities such as received calls, dialed
calls, missed calls etc.
If you click on received calls, then another activity (i.e., screen showing the list of received calls)
is opened.
And if you click on one of the received call, then another activity showing the information about
the received call (such as the phone number of received call, the time at which it was received
etc.) is opened. And if you want to make a call, another activity showing the number keypad is
opened.
Services
If you want the music to play in the background or if you want some video to be downloaded
while you are browsing over the internet ‒ services provide feasibility for the music to play in
the background or video to be downloaded while you are browsing over internet.
1043
1752
Broadcast Receivers
Pop up notifications such as low battery, charging, Power got connected to the mobile device,
Power got disconnected from the mobile device, A headset was plugged in, A headset was
plugged out.
Popup notification
by broadcast
receiver
Content Providers
If you type a request for the meaning of a word in the search engine of user dictionary
application
User dictionary application sends the request to content resolver and the content resolver sends
the request to the content provider and the content provider fetches the information from the
database and directs it to the content provider and then from content provider to content resolver
and finally from content resolver to user application.
Intent
1044
1753
Activity 1 Activity 2
View photo
When you press view photo, intent (message) is sent to the android operating system
to open another activity (i.e., activity 2) which display the photo
Different android mobile devices possess different configurations. After running and testing your
android application on emulator (the component that allows the testing of android application
without the necessity to install the application on a physical Android based mobile device) you
need Android Virtual Device (AVD) to test whether the application is compatible with a
particular android mobile device configuration before installation of the app into that mobile
device.
1045
1754
Understand the problem
[Algorithmic Problem Solving]
Decide an algorithm
Prove correctness
Brute force algorithm finds a solution by trying all possible answers and picking the best one.
If there is a lock of four digit PIN. The digits to be chosen from 0-9 then the brute force will try all
possible combinations one by one like 0001, 0002, 0003, 0004, and so on until we get the right PIN. In
the worst case, it will take 10,000 tries to find the right combination.
1755
Divide-and-conquer technique
Problem of size n
n n
subproblem 1 of size subproblem 2 of size
2 2
Numerical stability refers to how errors introduced during the execution of an algorithm affect the result
1756
Persistent Data Structure Ephemeral Data Structure
Data structure that always preserves the Data structure that do not preserves the previous version
previous version of itself when it is modified of itself when it is modified
Packages
Backtracking
If the current solution is not suitable, then eliminate that and backtrack (go back)
and check for other solutions.
1757
Time complexity of an program Space complexity of an program
The amount of time taken by an program to The amount of memory space used by an
complete its execution as a function of the program to complete its execution as a function
length of the input of the length of the input
int d = a + b + c;
return(d);
}
C# C# Complier
language
Compiler
Prolog Prolog Complier
in
F# F# Complier Common
language runtime
Scheme Scheme Complier
Languages Compilers
Hardware
Microsoft's Visual Studio.Net programming environment or
Stimulator
1758
Declarative programming → specifies what is to be done rather than how to do it
Imperative programming: provides step by step instructions on how to solve the problem
Ada
ALGOL
Assembly language
BASIC
Blue
C
C#
C++
COBOL
D Easy to read and learn
FORTRAN Solution path is very easy for
Go
Groovy beginners to understand
Java
Julia
Lua
MATLAB Optimization and extension is more
Modula difficult
MUMPS
Nim Higher risk of errors when editing
Oberon
OCaml
Pascal
Perl
PHP
PROSE
Python
Ruby
Rust
1759
Imperative programming (PHP):
$firstnames = array_values($participantlist);
Imperative programming
x = 5
y = 11
z = x + y
WriteLine(z)
If x Mod 2 = 0
End If
1760
Repetition: Repeat a block of code while a condition is true. There is no
limit to the number of times that the block can be executed.
x = 2
WriteLine(x)
x = x * x
End
Declarative programming
1761
Easy to read Hard to read
Easy to do testing and debugging Hard to do testing and debugging
:- initialization(main).
main :- write('Hello World!').
Hello World!| ?- Output on the screen Some basic features of Prolog include:
pattern-matching mechanism
For every input array of length n ≥ 1, the MergeSort backtracking strategy that searches for possible
algorithm performs at most solutions
Recursion Iteration
Uses Uses
selection structure
repetition structure
A program is called recursive when a statement A program is called iterative when a loop repeatedly
in a function calls itself repeatedly executes until the controlling condition becomes false
Reduces the size of the code Makes the code longer
Slow in execution Fast in execution
1762
#include<stdio.h> #include<stdio.h>
} return 0;
int main() { }
return 0;
Factorial of 5 is 120
Procedural abstraction refers to using subprograms to hide information about how problems
are solved.
1763
Memory (RAM)
Yes
Yes No
1764
Repeating patterns Loops
Directions Algorithms
Order of steps Sequence
Completed project Program
Problem solving Debugging
Paths to completion Conditionals
Break into steps Decompose
Amount Value
Java Desktop GUI application (AWT or Swing api), Applets, online shopping
sites, internet banking, jar files for secured file handling, enterprise
applications, mobile applications, gaming software.
C Operating Systems, Embedded systems, Database management systems,
Compiler, gaming and animation.
Python Machine learning, Artificial Intelligence, Data analysis, face detection and
image recognition Software.
C++ Banking and trading enterprise software, virtual machines and compilers.
Visual Basic .NET Windows services, controls, control libraries, Web applications, Web
services.
C# Desktop applications like a file explorer, Microsoft office applications like
Word, Excel, Web browsers, Adobe Photoshop.
JavaScript Client side and server side validations, DOM handling, developing web
elements using jQuery (JS library).
PHP Static and dynamic websites and applications, Server side scripting.
SQL Querying database, CRUD operations in database programming, creating a
stored procedure, triggers, database management.
Objective – C Apple's OS X, iOS operating system and APIs, Cocoa and Cocoa Touch.
1765
A Prior Analysis A Posterior Analysis
Theoretical analysis of an algorithm Empirical analysis of an algorithm
It will give approximate answer and is independent It will give exact answer and is dependent on
of language of compiler and types of hardware language of compiler and type of hardware
encryption key
decryption key
1766
unencrypted message → 1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
4 2 3 2 4 2 3 2 4 2 3
1 2 3 4 5 6 5 4 3 2 1
+ 4 2 3 2 4 2 3 2 4 2 3
---------------------
5 4 6 6 9 8 8 6 7 4 4
5 4 6 6 9 8 8 6 7 4 4
4 2 3 2 4 2 3 2 4 2 3
5 4 6 6 9 8 8 6 7 4 4
- 4 2 3 2 4 2 3 2 4 2 3
---------------------
1 2 3 4 5 6 5 4 3 2 1
1767
1 2 3 4 5 6 5 4 3 2 1 → unencrypted message
single key
Algorithmic Trading
Develop
Programmer Code
1768
#include<iostream>
using namespace std;
int main ( )
{
long long a = 123456789;
long long b = 987654321;
cout << a*b << "\n";
return 0;
}
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
ll a = 123456789;
ll b = 987654321;
cout << a*b << "\n";
return 0;
}
121932631112635269
1769
Data Type
byte
short
float double
int
long
double float
byte 1 byte
short 2 bytes
1770
int 4 bytes
long 8 bytes
float 4 bytes
double 8 bytes
char 2 bytes
int b = 20
Datatype (keyword)
1771
Output on the screen:
......hi......
1772
Output on the screen:
Find problem
1773
Mathematical theory
Activation of a block → a time interval during which that block is being executed
1774
Fetch instruction
Decode instruction
Memory cycle
Python:
1775
# Accessing the last item using negative indexing
print(a [-1])
Slicing a = [2, 3, 4, 5, 6, 7, 8, 9, 10]
# printing a part of the list
print(a [0:3])
Concatenation a = [2, 3, 4, 5, 6, 7, 8, 9, 10]
b =[11,12]
# adding and printing the items of two lists
print(a + b)
Repetition b =[11,12]
# create a multiple copies of the same list
print(b*3)
Updating a = [2, 3, 4, 5, 6, 7, 8, 9, 10]
# updating the list using index value
a[2]=13
print(a)
Membership a = [2, 3, 4, 5, 6, 7, 8, 9, 10]
# returns true if item is present in list. otherwise returns false
print (5 in a)
print (13 in a)
Comparison a = [2, 3, 4, 5, 6, 7, 8, 9, 10]
b =[11,12]
# returns true if all items in both lists are same. otherwise returns false
print(a==b)
# list
a =[12, "John", "C++", 78.5]
print(a)
# tuple
b =(13, "Joseph", "Java", 88.5)
print(b)
# dictionary
1776
c ={"Roll no":15, "class":"Python", "percentage":98.50}
print(c)
Command:
Description:
Command:
yum check-update
Description:
Find how many of installed packages on your system have updates available {CentOS}
1777
Command:
yum grouplist
Description:
Command:
yum repolist
Description:
Command:
Description:
1778
Command:
yum history
Description:
Command:
Description:
Command:
netstat –r
Description:
1779
Type casting is a way to convert a variable from one data type to another data type.
Automatic type conversion: Type conversion done by the compiler wherever required
1780
Mutable objects → The objects in which you can change the fields and states after the
object is created.
Immutable objects → The objects in which you cannot change the fields and states after
Open a connection
Execute a query
Machine Learning
1781
Combines data from multiple sources
Applies logic and mathematics to data to
provide insights for making better quick
decisions
Tableau → data visualization tool
Analyze multiple independent datasets to gain
the combined insight
Visualize and create interactive, shareable
dashboards.
Requirement Analysis
Testing strategy is defined
Testing team prepares the test data for testing
Set up the test environment
Test analysts test the data and compare the expected and actual results.
Note the summary of the bugs removed and errors found during the software development
life cycle.
1782
bash (Bourne Again Shell)
zsh (Z Shell)
free -m
vmstat
Commands for Checking Memory Usage in Linux
top
htop
Defect density:
The process states in Linux:
The number of flaws that were identified during software
1783
Concept Description
Abstraction Hides the implementation details and only provides the functionality to the user
Encapsulation Wraps up the data and code together as a single unit
Inheritance Where one class acquires the properties of another
Polymorphism The ability of a variable, function or object to take multiple forms
2 types of polymorphism:
Used for
• Method Overriding
• Code Reusability
2 types of Constructor:
• Default Constructor → can be called with no arguments.
• Parameterized Constructor → can be called with specific number of arguments.
Exception handling:
1784
Differences between C, C++ and Java:
C C++ Java
(OOP) Oriented
language
Developer Dennis Ritchie in 1972 Bjarne Stroustrup in 1979 James Gosling in 1991
(Compiler + interpreter)
Virtual Machine)
Pre-processor directives Support header files Supported (#header, #define) Use Packages (import)
(#include, #define)
inheritance
(Polymorphism) supported
destructor
Storage Classes Supported ( auto, extern ) Supported ( auto, extern ) Not supported
1785
Write a python program to get all links from a webpage
urls = []
urls.append(url.get('href'))
print(urls)
Write a python program to Print all Integers that Aren’t Divisible by Either 2 or 3
# incrementing 'i'
i = i+1
1786
Write a Python program which iterates the integers from 1 to 20. For multiples of
3 print "Albert" instead of the number and for the multiples of 5 print "Elsa".
For numbers which are multiples of both 3 and 5 print "Elsa Albert".
for i in range(21):
if i % 3 == 0 and i % 5 == 0:
print("Elsa Albert")
continue
elif i % 3 == 0:
print("Albert")
continue
elif i % 5 == 0:
print("Elsa")
continue
print(i)
Write a Python program to convert seconds into hours, minutes and seconds
def convert(seconds):
seconds = seconds % (24 * 3600)
hour = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
x = 98765
print(convert(x))
1787
Data Science
(Evaluate the data to derive knowledge and insights and make future predictions)
Conventional Programming:
Machine Learning:
1788
Azure Machine Learning (Azure ML):
A platform for building and managing machine learning applications in the cloud. It
is intended to assist data scientists and machine learning engineers in utilizing their current
model development and data processing skills and frameworks
Bandits: A class of algorithms where users repeatedly select from or make judgments in
response to various options
Box plot: A diagram that illustrates how the data vary in terms of pattern
Causal modeling: Build a model to explain the connections between ideas connected to a
particular phenomenon
Data Partitioning: The process of dividing data over several tables, drives, or locations in
order to speed up query processing or make databases easier to maintain
Data Product: Any tool or software that processes data and produces output
Dichotomous: A result with only two possible values. For example: a coin tossing
experiment's results are dichotomous ("head" or "tail")
Discriminant Analysis: A statistical method that divides data into distinct groups
according to how well they perform on one or more quantitative predictor factors
1789
Face validity: The degree to which a test is seen as covering the idea that it is meant to
measure
Factor Analysis: A method for breaking down a large number of variables into a smaller
number of factors
Family-wise Type I Error: The likelihood that we will incorrectly assume that at least one
pair of populations differs, even if all samples come from the same population
Frequency Interpretation of Probability: When an experiment is repeated a very
large number of times, the probability of an event is the proportion of times the event takes place
Likelihood Ratio Test: A statistical test that compares the likelihood ratios of two models
to assess the goodness of fit of the models
Meta-analysis: An epidemiologic study design that is rigorous, systematic, and utilized to
methodically evaluate the findings of earlier research in order to draw conclusions about that
body of research
Normality: A property of a random variable that follows the normal distribution
1790
Step-wise Regression: The iterative process of building a regression model step-by-step,
including choosing independent variables to be included in the final model
Stratified Sampling: A kind of sampling procedure in which the entire population is split
up into smaller groups to finish the sampling process
Systematic Error: The expected value of the overall error
Test-Retest Reliability: A reliability score that is achieved by administering the same test
to a set of individuals twice over time
Two-Tailed Test: A kind of hypothesis testing where the null hypothesis is disproved if the
observed sample statistic deviates significantly from the critical value in either direction (higher
than the positive critical value or lower than the negative critical value)
MATLAB: A platform for programming and numerical computing used by millions of
engineers and academics to interpret data, construct algorithms, and make predictions
Logic programming: A programming methodology in which calculation is performed
using a knowledge base of facts and regulations. LISP and Prolog are two logic programming
languages employed in the development of Artificial Intelligence
H2O.ai: A powerful AI cloud platform designed to build, operate and innovate with AI in any
environment easier and faster
Tidyverse
Complex structured data: Data that cannot be easily processed by structured query
languages and tools because they are made up of two or more intricate, interrelated parts
Key-value Database: A kind of non-relational database that stores data via the simple
key-value approach
Topological Data Analysis: A method that focuses on the structure of complex data
to find clusters and any statistical significance that may be present
1791
Data Catalogue: A technique for organizing, categorizing, and documenting collections
of data in a data repository that simplifies searching and, frequently, also includes features
that enable users to review or remark on data-sets, benefiting future users' queries
Data Democratization: A procedure for increasing Data accessibility within an
organisation, especially for non-specialist staff
Operating Model: An organization's operating model that describes how an organization
operates, including the tasks it does, how they are carried out, and the individuals,
procedures, and technology involved
Data Owner: The individual responsible for an organization's classification, protection,
utilization, and quality of one or more data sets
Data Processor: An individual, corporation, or other entity that handles personal data
on behalf of the data controller
Data Education: Inform individuals about the utilization of data and its significance to
the enterprise organisation
Embedded BI: The incorporation of data visualizations, dashboards, and reports within
an application
Management Information (MI): Any information obtained to support business
decisions
Single Version of the Truth: The process of providing decision-makers with precise
data in the form of responses to extremely strategic questions
Single Source of Truth: A technique for organizing information models and related
conceptual frameworks so that each piece of data is recorded exactly once
Analysis Facility: A bundled-up collection of the tools and data required to perform a
certain set of analysis
Chart (Graph): A method for organizing and displaying data with the ultimate goal of
making it simpler to interpret and, in particular, identify patterns
Clickstream Analytics: The monitoring and evaluation of website traffic in terms of
page views, unique visitors, and repeat visitors
Data Asset: A program output file, document, report, database, or webpage that business
organizations utilize to make money
1792
Data Controller: An organization responsible for the gathering, storing, using, and
erasing of personal data
Data Issue Management (DIM): A method of eliminating or lessening the effects
of barriers that limit the efficient use of data
Data Maturity: A way to evaluate how effective an enterprise organization's data
analysis is
Data Protection Officer (DPO): A senior manager in charge of making sure that
his/her company complies with the relevant data protection laws when handling the personal
information of its employees, clients, vendors, or any other individuals (also known as data
subjects)
Data Sourcing: The procedure of obtaining Data from multiple Data Sources, including
Data Repositories, Databases supporting Transactional Systems, website logs or other flat-file
outputs, APIs, or external sources of data
End User Computing (EUC): Platforms and computer systems that assist non-
programmers in developing applications
Flat-file: A kind of database that saves information in plain text
Gamification: The design principles employed in the game to boost consumer interest in
non-game enterprises
Apache Sqoop: A tool developed to move data between relational database servers and
Hadoop
Weather Data: The data patterns and trends used to monitor the atmosphere
1793
Intelligent matching: A method of managing data in which a database's contents are
identified, indexed, and retrieved using a variety of artificial intelligence-based algorithms for
data matching and sorting.
Expressiveness: The ability of a knowledge representation framework to communicate
the key characteristics of a given problem
Parser: A program that determines one or more possible ways a sentence in a language
could have been constructed using the grammar rules
Problem description: A summary of a problem that needs to be solved
Weak method: A method of problem-solving that can be used to solve a range of issues
but is not ensured to be effective or yield a solution
Decision Aid: A software that facilitates decision-making by individuals, especially for
complicated issues where a high level of knowledge is required
Human-Centered Computing: Computers and other devices should be constructed
to effectively meet user needs and expectations
Plan Recognition: Prediction of an interactive system's top-level strategies from its
observed actions
Programming by Demonstration: A set of end-user programming methods that
Toy System: Small-scale use of an idea or methodology that works well for testing a few
1794
Black Box Algorithms:
An algorithm that has a black box structure prevents the user from seeing how it
functions within. The output of this algorithm is determined by correlating specific
data attributes across millions of input data points.
Cybernetic Organism:
Weight: The degree to which two neurons from two different layers of a neural network are connected
– John Johnson
1795
Big data
A collection of technologies and strategies needed to handle, evaluate, and preserve the large amount of
data. Big data operates under the assumption that the more one know about a topic, the more accurately
one can learn new things and make predictions about what's to come. Today, it is applied in a variety of
fields, including agriculture, environmental conservation, medicine, and sports.
Space analysis:
Administrative data:
1796
Analogue data
Any information that is physically captured, whether it be through electrical or optical means, and stored
Anomaly:
Black box: Any device whose operations and functionality the user cannot access or understand.
Data Catalogue → A curated set of metadata regarding datasets and their data components.
Data dredging
Derived research data: Research data that are produced by merging or analyzing 'raw' data,
frequently reproducible but intensive.
E-Infrastructure: A system that brings together communications, computation, and digital
technologies to promote teamwork and research.
Experimental research data: Research findings from experiments that is frequently
reproducible but intensive.
Informatics: The discipline of gathering, classifying, storing, retrieving, and sharing information.
1797
Research Data Lifecycle
Reusing Data
Creating Data
Processing Data
Analyzing Data
Preserving Data
Research data produced by test models, where the model and metadata may be
more significant than the model's output data.
Stream processing
The process of performing calculations on individual data elements as they pass through a system
Secondary Data:
Existing data that is being used for a different objective from the one for
which it was originally acquired
1798
Data quality checklist
A group of researchers and research organizations came up with the FAIR Data Principles (Findable,
Accessible, Interoperable, and Reusable), which were published in Scientific Data in 2016 and serve as a
set of guiding principles for the reuse of digital assets.
Digitisation Digitalisation
Information that is being transferred from a The method of utilizing digitization to enhance
physical format to a digital one business procedures
AI Literacy:
Knowledge of what artificial intelligence is and what it needs to function. With the aid of this
knowledge, it is feasible to assess AI technologies critically, interact with AI systems, work
with them, and use them as useful tools for one's own work.
1799
Customer analytics:
The analysis of a certain consumer base based on data. This makes it possible to identify valuable client
relationships and consumer interests in order to develop appropriate, unique offers
Datafication:
Explains the creation of data that results from the digitization of everyday activities
and aspects of existence
Data Thinking
To successfully create data products and data strategies, data thinking unites data
science and design thinking methodologies. Data Thinking takes into account and
addresses issues from the user's perspective.
1800
term direction of economic outlook, trend analysis makes use of previous data, such as
price fluctuations and transaction volume.
1801
Best Linux Books that Every Superuser Should Read:
Linux in a Nutshell
Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security
in Kali
Book by OccupyTheWeb
Linux Command Line and Shell Scripting Bible
Linux Administration: The Linux Operating System and Command Line Guide for
Linux Administrators
Linux Bible
Linux administration
Linux Essentials
example in the sense that it shows you can set people to work in
− James Surowiecki
Best Programming Books that Every Programmer Should Read:
C:
Head First C
Expert C Programming
Book by K. N King
Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep
Avoiding (Like C)
Let Us C
A Book on C: Programming in C
Extreme C: Taking You to the Limit in Concurrency, OOP, and the Most Advanced
Capabilities of C
Book by Kamran Amini
Let Us C Solutions
Introduction to C Programming
C - In Depth
C How to Program
Understanding Pointers In C & C++: Fully Working Examples and Applications of Pointers
C++:
C++ Primer
A Tour of C++
More Effective C++: 35 New Ways To Improve Your Programs And Designs
C++ Programming
Book by D. S. Malik
Professional C++
C++ High Performance: Master the Art of Optimizing the Functioning of Your C++ Code
Data Parallel C++: Mastering DPC++ for Programming of Heterogeneous Systems using
Book by James Brodman, Michael Kinsner, Xinmin Tian, Ben Ashbaugh, John Pennycook,
James Reinders
Modern CMake for C++: Discover a Better Approach to Building, Testing, and Packaging
Your Software
Expert C++: Become a Proficient Programmer by Learning Coding Best Practices with
Learn C++ Quickly: A Complete Beginner's Guide to Learning C++, Even If You're New to
Programming
Hands-On Design Patterns with C++: Solve Common C++ Problems with Modern Design
JAVA:
Effective Java
Thinking in Java
Book by Bruce Eckel
Core Java
Test Driven: Practical TDD and Acceptance TDD for Java Developers
Spring in Action
Head First Object-Oriented Analysis and Design: A Brain Friendly Guide to OOA&D
Java Performance: The Definitive Guide: Getting the Most Out of Your Code
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
Java Performance
PYTHON:
Fluent Python
Learn Python the Hard Way: A Very Simple Introduction to the Terrifyingly Beautiful
Automate the Boring Stuff with Python: Practical Programming for Total Beginners
Book by Al Sweigart
Python for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython
Learning Python
Book by Al Sweigart
Python Data Science Handbook: Essential Tools for Working with Data
Python in a nutshell
Book by Al Sweigart
Python Programming for the Absolute Beginner
The Python Bible 7 in 1: Volumes One To Seven (Beginner, Intermediate, Data Science,
Coding for Kids: Python: Learn to Code with 50 Awesome Games and Activities
Learn More Python 3 the Hard Way: The Next Step for New Python Programmers
HTML:
Book by Jo Foster
Textbook by M. G. Martin
CSS:
CSS in Depth
CSS mastery
Learn CSS in One Day and Learn It Well: CSS for Beginners With Hands-On Project
CSS Master
JAVASCRIPT:
JavaScript: The Definitive Guide: Master the World's Most-Used Programming Language
Programming JavaScript Applications: Robust Web Architecture with Node, HTML5, and
Modern JS Libraries
JavaScript Enlightenment
Beginning JavaScript
JavaScript Patterns
Object-Oriented JavaScript
Maintainable JavaScript
Book by Nicholas C. Zakas
DOM Enlightenment
Testable JavaScript
Book by Al Sweigart
The Road to Learn React: Your Journey to Master Plain Yet Pragmatic React. Js
Learning TypeScript
Functional Techniques
PHP:
The Joy of PHP: A Beginner's Guide to Programming Interactive Web Applications with
Learning PHP, MySQL, JavaScript, CSS and HTML5: A Step-by-Step Guide to Creating
Dynamic Websites
Programming PHP
Book by Rasmus Lerdorf
PHP and MySQL: Novice to Ninja: Get Up to Speed With PHP the Easy Way
Learning PHP, MySQL & JavaScript: With JQuery, CSS & HTML5
PHP and MySQL in easy steps, 2nd Edition: Updated to cover MySQL 8.0
Mastering PHP 7
PHP 8 Programming Tips, Tricks and Best Practices: A Practical Guide to PHP 8 Features,
PHP: Learn PHP in One Day and Learn It Well. PHP for Beginners with Hands-on Project
PHP Cookbook
Drupal 9 Module Development: Get Up and Running with Building Powerful Drupal
WordPress Complete
Learning PHP 7
Mastering The Faster Web with PHP, MySQL, and JavaScript: Develop State-of-the-art
PHP Microservices
Professional CodeIgniter
PHP Programming for Beginners: Key Programming Concepts. How to use PHP with
ALGORITHMS:
Introduction to Algorithms
Grokking Algorithms: An Illustrated Guide for Programmers and Other Curious People
Book by Aditya Bhargava
Algorithms
Algorithm Design
Algorithms in a nutshell
Data structures and algorithms made easy in Java: data structure and algorithmic puzzles
Programming Skills
Contests
Algorithms Unlocked
The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake
Our World
Spies, Lies, and Algorithms: The History and Future of American Intelligence
Designing Distributed Systems: Patterns and Paradigms for Scalable, Reliable Services
A Programmer's Guide to Computer Science: A virtual degree for the self-taught developer
Concrete Mathematics
Textbook by Donald Knuth, Oren Patashnik and Ronald Graham
DATA STRUCTURES:
Book by J. R Hubbard
Java Structures
LINUX:
Linux bible
Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali
Book by OccupyTheWeb
Linux Administration: The Linux Operating System and Command Line Guide for Linux
Administrators
Linux in a Nutshell
Learn Linux Quickly: A Beginner-friendly Guide to Getting Up and Running with the
World's Most Powerful Operating System
The Ultimate Kali Linux Book: Perform Advanced Penetration Testing Using Nmap,
Metasploit, Aircrack-Ng, and Empire
Programming
Linux Kernel Debugging: Leverage Proven Tools and Advanced Techniques to Effectively
Bash cookbook
Linux for Beginners: A Practical and Comprehensive Guide to Learn Linux Operating
Kali Linux Hacking: A Complete Step by Step Guide to Learn the Fundamentals of Cyber
Bash Pocket Reference: Help for Power Users and Sys Admins
DATABASE:
Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and
Maintainable Systems
Database Internals: A Deep Dive Into How Distributed Data Systems Work
Database Design and Relational Theory: Normal Forms and All That Jazz
Book by Christopher J. Date
Learning SQL
Foundations of databases
Pro SQL Server Relational Database Design and Implementation: Best Practices for
Seven Databases in Seven Weeks: A Guide to Modern Databases and the NoSQL Movement
Refactoring databases
SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and
SQL Cookbook
SQL Queries for Mere Mortals: A Hands-on Guide to Data Manipulation in SQL
Performance
build bigger and better idiot-proof programs, and the Universe trying to
− Andrew Hunt
One final thought:
If you feel that this information has been useful to you, please take a
moment to share it with your friends on LinkedIn, Facebook and
Twitter. Consider writing a brief review on Google Play Books if you
feel that this book has helped you in your programming career and you
have learned something worthwhile.
Thank you!