Skip to main content

2021 | Buch

Julia - Bit by Bit

Programming for Beginners

insite
SUCHEN

Über dieses Buch

The main goal of this book is to teach fundamental programming principles to beginners using Julia, one of the fastest growing programming languages today. Julia can be classified as a "modern" language, possessing many features not available in more popular languages like C and Java.

The book is organized in 10 chapters. Chapter 1 gives an overview of the programming process. It shows how to write a first Julia program and introduces some of the basic building blocks needed to write programs. Chapter 2 is all about numbers—integers, floating-point, operators, expressions—how to work with them and how to print them. Chapter 3 shows how to write programs which can make decisions. It explains how to use if and if…else statements. Chapter 4 explains the notion of ‘looping’, implemented using for and while statements. It also explains how to read data from a file and write results to a file. Chapter 5 formally treats with functions, enabling a (large) program to be broken up into smaller manageable units which work together to solve a given problem. Chapter 6 is devoted to characters and strings. In Julia, we can work with them as seamlessly as we do with numbers. Chapter 7 tackles array processing, which is significantly easier in Julia than other languages. Chapter 8 is about sorting and searching techniques. Sorting puts data in an order that can be searched more quickly/easily, and makes it more palatable for human consumption. Chapter 9 introduces structures, enabling us to group data in a form that can be manipulated more easily as a unit. Chapter 10 deals with two useful data structures—dictionaries and sets. These enable us to solve certain kinds of problems more easily and conveniently than we can without them.

This book is intended for anyone who is learning programming for the first time. The presentation is based on the fact that many students (though not all) have difficulties in learning programming. To overcome this, the book uses an approach which provides clear examples, detailed explanations of very basic concepts and numerous interesting problems (not just artificial exercises whose only purpose is to illustrate some language feature).

Inhaltsverzeichnis

Frontmatter
Chapter 1. Elementary Concepts
Abstract
In this chapter, we will explain the following:
  • How a computer solves a problem
  • The various stages in the development of a computer program: from problem definition to finished program
  • How a computer executes a program
  • What is a data type and its fundamental role in writing a program
  • The role of characters—the basic building blocks of all programs
  • The concepts of constants and variables
  • The distinction between syntax and logic errors
  • How to produce output in Julia using print/println statements
  • What is an escape sequence
  • How descriptive or explanatory comments can be included in your program
  • What is an assignment statement and how to write one in Julia
Noel Kalicharan
Chapter 2. Numbers
Abstract
In this chapter, we will explain the following:
  • Integer data types - Int, Int32, Int64
  • Floating-point data types - Float32, Float64
  • How to read Int and Float values
  • What happens when Int and Float values are mixed in the same expression
  • What happens when we assign Int to Float and vice versa
  • How to print an integer using a field width
  • How to print a floating-point number to a required number of decimal places
  • What happens when you use expressions with different types
  • Assignment operators
  • Updating operators
  • The functions trunc, ceil, floor, round
Noel Kalicharan
Chapter 3. Selection Logic
Abstract
In this chapter, we will explain the following:
  • What are Boolean expressions
  • How Julia represents Boolean values
  • How to write programs using if
  • How to write programs using if…else
  • How to write programs using if…elseif…else
  • How a program should be tested
  • Symbolic constants, why they are useful and how to use them
Noel Kalicharan
Chapter 4. The for and while Statements
Abstract
In this chapter, we will explain the following:
  • How to use the while statement to perform ‘looping’ in a program
  • How to find the gcd (also called hcf) of two numbers
  • How to find the sum and average of an arbitrary set of numbers
  • How to read data until there’s no more
  • How to find the largest and smallest of an arbitrary set of numbers
  • How to fetch (read) data from a file
  • How to send (write) output to a file
  • How to use the for statement to perform ‘looping’ in a program
  • How to produce tables using for
  • How to use break/continue in while/for statements
  • Nested for statements
Noel Kalicharan
Chapter 5. Functions
Abstract
In this chapter, we will explain:
  • Why functions are important in programming
  • How to write functions
  • What happens when a function is called
  • Where functions are placed in a program
  • Some important concepts relating to functions using several examples
  • How to write recursive functions—functions that call themselves
Noel Kalicharan
Chapter 6. Characters & Strings
Abstract
In this chapter, we will explain the following:
  • Some important features of character sets
  • How to work with character constants and values
  • How to declare character variables in Julia
  • How you can use characters in arithmetic expressions
  • How to read, manipulate and print characters
  • How to convert characters from one case to the other
  • How to test for end-of-line using \n
  • How to test for end-of-file using eof
  • How to compare characters
  • How to read characters from a file
  • How to convert a number from character to integer
  • How to compare strings
  • How to index into a string
  • How to create a string from pieces of another
  • How to fetch a word embedded among other data
  • How to write palindrome and Geography quiz programs
  • Array of Characters versus Strings
  • Some functions for the advanced user
Noel Kalicharan
Chapter 7. Arrays
Abstract
In this chapter, we will explain the following:
  • The difference between simple variable and array variable
  • How to declare and store values in an array
  • How to process elements of an array using a for loop
  • How to the calculate average and differences from average of a set of numbers
  • How to read the entire contents of a file as a String
  • How to write a Letter Frequency program
  • How to test if a file exists
  • How an array is passed as an argument to a function
  • How to find the sum, average of numbers stored in an array
  • How to use an array to keep several counts
  • How to pass an array as an argument to a function
  • How to find the largest and smallest values in an array
  • How to write a program to process the results of an election
Noel Kalicharan
Chapter 8. Searching, Sorting and Merging
Abstract
In this chapter, we will explain the following:
  • How to search a list using sequential search
  • How to sort a list using selection sort
  • How to sort a list using insertion sort
  • How to sort a list of strings
  • How to sort parallel arrays
  • How to search a sorted list using binary search
  • How to merge two sorted lists
Noel Kalicharan
Chapter 9. Structures
Abstract
In this chapter, we will explain the following:
  • What is a structure (struct)
  • How to declare a structure
  • How to pass a structure to a function
  • How to work with an array of structures
  • How to search an array of structures
  • How to sort an array of structures
  • How to declare/use nested structures
  • How to use structures to manipulate fractions
Noel Kalicharan
Chapter 10. Dictionaries and Sets
Abstract
In this chapter, we will explain the following:
  • What is a dictionary (Dict)
  • How to create and use dictionaries
  • How to implement a letter-frequency program using a Dict
  • What is a Set
  • Operations on sets: union, union!, intersect, etc.
  • How to use a Set to find all unique words in an input file
  • How to build a thesaurus from lines of synonyms
  • How to generate all combinations and permutations of a set
  • How to write a program to evaluate a hand in Scrabble
Noel Kalicharan
Backmatter
Metadaten
Titel
Julia - Bit by Bit
verfasst von
Noel Kalicharan
Copyright-Jahr
2021
Electronic ISBN
978-3-030-73936-2
Print ISBN
978-3-030-73935-5
DOI
https://doi.org/10.1007/978-3-030-73936-2