Digital Library
Coding for Absolute Beginners Master the Basics of Computer Programming with Python, Java, SQL, C, C , C, HTML, and CSS (Warner, Andrew)(Z-Library)
Warner, Andrew
Coding for Absolute Beginners Master the Basics of Computer Programming with Python, Java, SQL, C, C , C, HTML, and CSS (Warner, Andrew)(Z-Library)
编程
No Description
22
Views
0
Downloads
0.00
Total Donations
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
CODING FOR ABSOLUTE BEGINNERS Master the Basics of Computer Programming with Python, Java, SQL, C, C++, C#, HTML, and CSS ANDREW WARNER
Page
3
Copyright © 2021 by Andrew Warner. All rights reserved. No part of this book may be reproduced in any form on by any electronic or mechanical means, including information storage and retrieval systems, without permission in writing from the publisher, except by a reviewer who may quote brief passages in a review. Book and cover design : Raphael A. Printed in the United States of America ISBN-13 : 9798543586372 First Edition : July 2021 For information on translations, please e-mail andrew@aqpub.com, or visit http://www.aqpub.com
Page
4
DEDICATION M Y P A R E N T S For raising me to believe that anything is possible A N D M Y W I F E For making everything possible
Page
5
CONTENTS PREFACE CHAPTER ONE: WHAT IS PROGRAMMING? Problem Solving with Computer Programming Basics of Programming The Programming Environment CHAPTER TWO: JAVA Overview and Basic Syntax Java Identifiers and Modifiers Object, Classes, and Constructors Basic Data Types and Variables Operators, Control Statements and Decision Making Characters, Strings, Arrays, and Regular Expressions Files and I/O Object Oriented Java Abstract Class and Abstract Methods CHAPTER THREE: SQL AND DATABASE What is a Database? Structured Query Language (SQL) Advanced SQL Constraints and Useful resources CHAPTER FOUR: C Introduction and Simple Programs Starting with C Programming Methods and Variable declaration Data Types and Variables
Page
6
Loops and Functions Methods to Pass an Argument to a Function Arrays, Strings, and Linked Lists Pointers and Structures Structures C Programming files Essential Tips to Make C Programming Easy CHAPTER FIVE: C++ Basic Syntax Variables and Data Types Modifier Types and Storage Classes Flow Control Loops and Functions Arrays, Strings, Pointers, and References Object Oriented C++ Friend Function, Data Structures, and Encapsulation File Handling C++ Language Features and Support CHAPTER SIX: C# Overview and Basic syntax Datatypes and Variables Operators Functions and Methods Arrays, Strings, and Structures Classes and Objects Inheritance and Polymorphism Constructors Exception Handling
Page
7
Multithreading File I/O Advantages of learning C# CHAPTER SEVEN: PYTHON Overview and Basic syntax Features Variable Types, Basic Operators, and Data Types Flow Control Functions and Modules Object Oriented Python Regular Expressions Advanced Python Tips for Learning Python CHAPTER EIGHT: HTML Introduction and Overview Basic Tags and Attributes Tables, Images, and Frames Designing Meta Tags HTML Style Sheets Layout and Responsiveness HTML Templates Helpful Tips for Using HTML CHAPTER NINE: CSS What is CSS? Types of CSS Basic Syntax and Inclusion in HTML Importing CSS file
Page
8
Colors and Backgrounds Formatting and Design Margins and Padding Font and Text Text Links, Tables and Margins Lists, Icons, and Dropdowns Layers and Visibility Layout and Animations How to Effectively Use CSS CHAPTER TEN: PROGRAMMING ESSENTIALS Selecting the Programming Language Tips for Efficient Programming Strengthen Your Basic Skills CONCLUSION
Page
9
PREFACE Coding for Absolute Beginners is a complete and authentic guide for students who are determined to learn the best programming approaches, techniques, and methodologies. As the software industry is updated with the latest coding languages and tools every day, it is mandatory to adopt new skills and technologies to survive in the competitive market. Reading has always been a vital resource for students and learners as they can improve their performance and output by implementing the latest techniques and programming methodologies. This book is a successful programming manual covering all of the major programming languages, syntax, and best practices that are suitable for both beginners and professionals. Before entering into the programming world, there are several important factors that need to be looked at in order to develop sharp problem solving and analytical skills. Therefore, this book targets novice programmers and has been updated with solutions and answers to almost every question you might have about Java, SQL, C, C++, C#, Python, HTML, and CSS. I always emphasize the acquisition of basic knowledge and skills. This book will not make you a programmer in just one hour or overnight, but it will build a solid foundation for your programming career. After reading this book, your basic knowledge of programming will increase, as will your proficiency in any programming language. Many people have helped me in many ways in writing this book with their important feedback and encouragement and correcting various mistakes. I am eternally grateful to all of them. Especially, Mr. Steve, my then CS thesis supervisor at Harvard University. He knew more than a year ago that I was writing a programming book. After sending him the draft of my book in
Page
10
December (2020), his reply was- "I just have gone through your book. I have been thinking about writing a book like this for the last five or six years- you have done it- I do not need to do it anymore. thank you." On a personal level, I have to thank my wife Rachel and son Aaron for their never-ending patience and support. I hope that Coding for Absolute Beginners be your best friend in your programming journey and help you become proficient in computer programming. May the source be with you. </>
Page
11
CHAPTER ONE WHAT IS PROGRAMMING? Generally, programming is referred to as a set of instructions that the computer utilizes to complete certain tasks. This is also known as coding. Before delving into an in-depth discussion, you must be well aware of how programming works and how the set of instructions are processed by the computer. When you are able to follow the correct approach of writing computer programs, it can become quite easy to implement functions, operators, and syntax for any language. Moreover, programming is a way to communicate with computers through binary language for which programmers need to understand high level and low-level languages including syntax as well. In order to solve a problem with a computer, users are required to present the solution for the problem through a set of instructions which can be utilized to execute the program. As a program is a collection of instructions that are required to solve a problem, appropriate statements and functionality must be added in order to achieve the desired outcome. For example, if you are given the task to develop a program to add two integers (numbers), the set of statements that will perform the addition operation will be known as the program. The algorithm for adding two integers will be expressed through the statements of a particular computer language like C++, C, C# or Java. If the program is not able to execute properly, there might be a problem with your algorithm or syntax because the compiler or editor will be unable to execute the program if there are any type of errors or syntax mistakes. Programming can be better learned through practice and writing code rather
Page
12
than learning long methodologies or complex techniques. Although it might seem like a fun activity at the start, it can also turn out to be time-consuming and frustrating if you are not following the correct approach. Furthermore, this book will make it easier for beginners to choose the most suitable programming languages and enter the world of computer programming without much hassle. Problem Solving with Computer Programming In essence, a computer program is supposed to solve a specific problem by following a set of instructions. People can write a program by following multiple techniques and approaches. In order to solve a problem, you need to determine the code flow and fulfill the requirements step by step to achieve the desired output. In some cases, your computer program may not work even after hours of struggle because of inappropriate syntax or flow for which you need to focus on the sequence of instructions and computer programming language requirements. Using this example of preparing a wooden table, you would need to write down the instructions as follows: 1. Get the most suitable pieces of wood required to make the table. 2. Get the essential tools and equipment that will be used during the procedure. 3. Join the pieces and build your table. 4. Polish the end product to make it look attractive. When giving such instructions to the computer, you need to be more specific and precise because a computer cannot perform operations on its own. As it is created to follow instructions, your computer program should always follow an incremental approach in order to achieve the desired outcome. On the topic of the natural language of a computer, they are unable to understand human language and therefore, we need to communicate with the system through another language called binary code. Binary code is made up of a series of 1s and 0s and is the natural communicating language of computers. In order to help the computer understand human language, we
Page
13
use translators and editors for writing programs. Translators have the capability to convert the source code into the machine’s language. There are multiple types of translators known as Interpreters, Compilers, and Assemblers. Interpreters are generally used to interpret languages which are then processed line by line to run the final program. Moreover, any syntax errors or mistakes are also outlined by the interpreter so the programmer can clear out the mistakes and execute the program. With the help of compilers, the source code is converted to binary code through a compilation process and is then executed to deliver the output. If there are no errors or mistakes in the source code, all of the lines are translated and executed at once by the compiler. Moreover, computer programs are also known as Apps (application or application software) and are tailored to the environment or platform they are designed to run on. Apps are differentiated in the categories of desktop applications and mobile applications as well. Basics of Programming Introduction to Computer Programming Every computer program is a combination of procedures, processes, and algorithms that complete the source code. As this process combination can also be considered a representation of a software, the process is referred to as a series of actions to achieve an output whereas the procedure can be considered as a series of actions performed in a specific order. Algorithms are the main driving force of any program, also known as an ordered set of steps to solve a certain program or problem. There are different high level and low-level languages that can be used to write a computer program. Nowadays, programs and software are generally made by using popular languages which include C, C++, Java, Python, HTML, PHP, Ruby, and Perl. These languages are used to produce computer programs that are currently being used in various fields and industries including the medical, engineering, communication, household, and entertainment industries. Furthermore, computer programs are also being
Page
14
used to create graphics, web applications, and desktop applications as well. Elements and Basics of Computer Programming Usually, computer languages are a combination of several elements that allow programmers to achieve an expected output. These elements include the basic syntax, programming environment, data types, keywords, variables, decision making, basic operators, and functions. Moreover, in order to perform certain operations within a program, you need to apply other operations and use elements including loops, strings, characters, File I/O, and arrays as well. There are five different basic elements of programming that are also considered as the building blocks of any program. The elements are known as Input, Output, Arithmetic, Conditional, and Looping. Starting with the first element, Input is the process of getting commands and data into the computer, whereas the Output element has the functionality to deliver the results. If there are any sort of calculations or operations, the Arithmetic element is used along with the Conditional statement to test whether the condition is true or false. Environment, Data Types, and Basic Syntax Environment In order to run or execute a program, you must install or setup the required tool and environment for the language you are using. Moreover, beginners can also use a text editor to create computer programs if they find it difficult to install and configure the programming environments on their own. To execute the programs into binary format, it is mandatory that you use a compiler because the computer cannot understand a program directly if given in the text format. Moreover, the conversion of text into binary format is done by the Compiler through which programmers can run and execute the program as well. Programming languages including C, C++, C#, and Java need the compilation in binary format whereas other languages such as PHP, Perl, and Python can be compiled directly as well.
Page
15
Basic Syntax To make it easier for beginners, we will be starting from the grassroots level and write a “Hello World” program in C++. This sample program as written below will make it easier for you to understand and begin writing your first program. 1 2 3 4 5 6 7 8 #include <iostream> using namespace std; int main() { cout << "Hello World!"; return 0; } The output for this respective Hello World program is as follows: Hello World! Each program that is being written in C++ starts with #include <iostream> and main () which is also known as the main function. The program is then continued with functions, characters, loops, strings, or arrays depending on the requirements. In the program written above, main () is used as a function whereas cout is the standard output stream that is implemented to print “Hello World!”. At last, return 0; is written as the exit status of the program which is also necessary for program execution. If you are unable to execute the program, there might be some possible syntax errors or typing mistakes that are not being processed by the compiler. As it stops the program from compiling, small typing errors such as the omission of a single comma, semi-colon, or dot are most likely to be the cause. So, if you are not properly following the syntax as defined for the programming language, your program might not compile or execute in this case. Data Types Data types are an important part of various programming languages and are used when creating computer applications. As it classifies every object or variable that is being written in the program, data types tell the compiler how
Page
16
to use the provided data in order to perform certain operations. Generally, commonly used data types include integer, real, Boolean, characters, alphanumeric strings, and floating-point numbers. Briefed details of data types are given as follows: Date: 01/04/2015 Integer: 1,52,13424 Boolean: True/False String: ab, aabb Void: No data Long: 5325433253 Floating point number: 5.2341 Short: 0 Syntax As stated previously, a program is defined as a collection of elements and attributes that perform certain operations to deliver a specific output. With the C++ programming language, there is a predefined basic syntax that needs to be followed when writing programs. Let us briefly look at an overview of how the basic syntax of the programming language works. 1. Class: Class is a defined data type and has its own member functions and data members. For example: consider the class of a school, the data members will be teachers, students, admin staff, etc. 2. Object: An Object is an instance of a class that has their own behavior and states. For example, a car has different colors, models, specifications, etc. 3. Methods: Method is referred to as the behavior and is responsible for the execution and manipulation of different actions within the class. Programming Variables, Keywords, Operators, and Decisions Variables are an essential part of a computer program as they provide computer memory locations required to store values and data in a computer program. In order to save a value, you will have to create variables and assign them a proper name, store values into the variables, and retrieve the given
Page
17
values back from the variables. To get started with declaring variables, we will have to write the program as follows: #include <iostream.h> int main() { int a; } The above written program creates a variable named “a” and is specified by an int keyword. This means the variable can only store an int type value and you are not allowed to define “a” again to store another type of value in the variable. To store a value into the variable, just declare the number that you want to place in “a” after the declaration of a variable in the program. Keywords There are different keywords for every programming language that are used for various purposes. Although each language provides a complete set of reserved keywords, there is a common rule that needs to be followed while using the keywords. Same as float, int, long, and string, other keywords that are mostly used in every programming language are as follows: Else Switch Goto Static Case Break Enum For If Union Double Private
Page
18
Operators Operators are the key aspect of any programming language and are required to perform certain operations or logical computations. As they are generally used for mathematical calculations, we can solve complex equations by using various expressions in the program. There are two kinds of operators that are generally used in programming languages: 1. Arithmetic Operators: Operators that are used to conduct mathematical and arithmetic operations. For example: +,-,/,--,++,*. Binary Operators: Operators that work with other operands such as +,-,/,*. Unary Operators: Operators that are used to work with a single operand. For example: ++,--. 2. Relational Operators: These are the most commonly used operators that tell us whether one operand is equal to another or not. For example: ==, <==, <==, >==. Here is a table detailing basic operators and their functionality within the program: Operator Functionality + Addition of two operands - Subtraction of two operands / Division * Multiplication == Check whether the two operands are equal or not >= Check if the left operand is greater than or equal in value as compared to the right operand <== Check if the left operand is less than or equal in value to the right operand
Page
19
Logical Operators are also an essential part of all programming languages. They are used to obtain certain decisions in various scenarios. These operators are AND, OR, and NOT. They are used to prove true or false statements as well. Decisions Decision making is a process in which the programmer has to select one option based on the two or more given conditions. You will have to test whether the condition is true or false and present the correct output. For different programming languages, the decision-making statements are briefed as follows: ‘If’ statement ‘Else’ statement Switch ‘Else if’ statement Conditional Operator Programming Characters, Arrays, and Strings In programming languages, Char type is used to store characters and letters. They are also responsible for storing values and delivering output whenever the character is called within the program. You are only allowed to store a single-digit number or alphabet inside the single quotes such as &, @, * or +. The example code for defining characters is as follows: Char ch1 = ‘a’. Arrays An Array is a data structure that has the capability to store a sequential number of elements of the same type and is generally of a fixed size. As it is comprised of contiguous memory locations, it is also known as the set of elements stored under the same name. If you are writing a program to store 10 integers in sequence, creating an array of 10 will be the best possible
Page
20
solution. This is how an array of a fixed number of values is declared: int data[10]; The two popular types of array are known as: 1. One-dimensional arrays. 2. Multi-dimensional arrays. Accessing arrays After you are done with the declaration, you can easily access the elements through indices. Arrays have 0 in the first index and the if the size of an array is n, you will have to use the condition n-1 to access the last element. To initialize the array, you can follow the pattern as follows: int arr[5] = {1, 2, 3, 4, 5}; Arrays allow the programmers to store data into individual variables without defining every variable specifically. Similar to other data types, arrays are declared by using [ and ] brackets, and once the array has been declared, you can assign the values. There are different ways to create, assign, and declare arrays in a program. Declaration In order to declare arrays, you must remember that array size must be an integer greater than 0. An array can be declared as follows: Type arrayName [ arraySize ]; Initialization To initialize an array, you can use the statement mentioned below: Int Arr[5] = { 23,45,53,64,73} Strings String is a data type that is used in programming languages to represent an array of characters. To declare and initialize a string, you need to follow the same structure as the arrays. There are different techniques and ways to write
The above is a preview of the first 20 pages. Register to read the complete e-book.
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
📚
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later