15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using Keywords as Building Blocks 129<br />

Ask <strong>for</strong> the user’s annual salary<br />

Figure 1-1: If<br />

you put<br />

enough<br />

commands<br />

together,<br />

you can<br />

create any<br />

type of<br />

program.<br />

Define the tax rate as 35%<br />

Multiply the user’s salary by the tax rate<br />

Display this result on the screen<br />

A “program” <strong>for</strong> calculating the amount of taxes<br />

you owe based on your salary.<br />

Commands<br />

Every <strong>programming</strong> language provides a list of commands dubbed keywords<br />

or reserved words. By typing keywords one after another, you can tell the<br />

computer what to do.<br />

A <strong>programming</strong> language’s keywords act like the letters of the alphabet. Type<br />

letters in different combinations and you can create different words. Type<br />

keywords in different combinations and you can create different commands,<br />

as shown in Figure 1-2.<br />

Book II<br />

Chapter 1<br />

How Programs<br />

Work<br />

Salary = input(”Enter salary:”)<br />

tax_rate = 0.35<br />

Figure 1-2:<br />

Multiple<br />

keywords,<br />

along with<br />

various<br />

symbol<br />

characters,<br />

can create<br />

a single<br />

command.<br />

tax_owed = salary * tax_rate<br />

print “Your owe=”, tax_owed<br />

Program commands consist of keywords and<br />

symbols such as equal signs (=) and<br />

multiplication signs (*).<br />

Keywords

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!