CODING FOR BEGINNERS USING PYTHON: A HANDS-ON, PROJECT-BASED INTRODUCTION TO LEARN CODING WITH PYTHON by LUTZ ERIC & MATTHES MARK

CODING FOR BEGINNERS USING PYTHON: A HANDS-ON, PROJECT-BASED INTRODUCTION TO LEARN CODING WITH PYTHON by LUTZ ERIC & MATTHES MARK

Author:LUTZ, ERIC & MATTHES , MARK [LUTZ, ERIC]
Language: eng
Format: epub
Publisher: CODING AND PROGRAMMING ACADEMY
Published: 2020-08-03T16:00:00+00:00


if a > b:

a = a + b

print(a )

else:

print(b)

print(a)

Determine what the output will be if you run the lines above.

In some cases, you want to check multiple alternative conditions. For this, you use elif. It allows you to create one or more alternative conditions to the if condition.

When the if condition is met, only the commands under the if statement will run. When the if condition is not met but the elif condition is met, only the commands under the elif statement will run. When neither the if condition nor the elif conditions are met, only the commands under the else statement are run. Run the following block of code together.

if a == b:

print(a+b)

elif a < b:

print(a )

else:

print(b)

For Loops

For loops are used to perform the same commands on a list’s elements. Just as with if statements, you will need to run everything indented under the for statement along with the for statement.

Run the following for loops:

a = [1,2,3,4,5,6]



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.