Book Image

Learn Q# Programming

By : Bhagvan Kommadi, Aneesh K Johny
Book Image

Learn Q# Programming

By: Bhagvan Kommadi, Aneesh K Johny

Overview of this book

<p>This book covers the fundamentals of quantum computing and programming with Microsoft’s Q# language. The reader will learn how to design, test and debug algorithms for different quantum applications.</p> <p>The primary focus of this book will be to give the audience an idea about how to get started with the concepts, different aspects, and theories of quantum computing operations, algorithms etc. Through this book, the developer will get a basic idea about the Microsoft Quantum Tool Kit and how to use the embedded Q# language. This will enable the reader to formalize and convert different real world problems to quantum algorithms and optimize them to use with a future quantum computer.</p> <p>By the end of the book, you would have successfully learned to create quantum programs of your own.</p>
Table of Contents (11 chapters)

Q# constructs


Symbol binding, statements, and calling methods are related to Q# constructs in the programming language. Statement types are listed as below.

  • Declaration 
  • Expression
  • Selection
  • Iteration
  • Jump 
  • Exception handling
  • Checked and UnChecked
  • Labeled
  • Empty

Symbol binding

The Q# symbols are of the following types:

  • Mutable
  • Immutable

Mutable symbol can be modified after it is bound. Mutable symbol value is declared as shown below:

mutable  j=9

The above statement binds j as an integer with value 9.

For changing the value of a mutable symbol, set keyword is used. The example is shown below:

set j = 10;

The above statement will update the value of the variable j to 10.

Immutable symbols are declared with  let expression. An immutable symbol cannot be modified after it is bound.

let j = 9;

The above statement will bind the symbol j as an integer with value 9.

Statements

Declaration statements are shown in the above section. The example is shown below:

let k=11;

Expression statements like range expression is written...