SlideServe
Menu
Préférences
© SlideServe · v2026

Control Structures

jerrypeterson avatar
8 diapositives · 120 Views · Jan 03, 2020

Learn about the syntax and usage of if statements in Python's control structures. Explore different examples to understand how to create decision-making steps in your programs.

Control Structures - slide 1
01 / 8Control Structures
1 / 17

Télécharger la présentation

Control Structures
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Control Structures If Else Statement

  2. S S E …consecutive steps (or groups of steps) processed one after another in the order that they arise. Q U A bit like reading through a cooking recipe, one line at a time. E N C E

  3. Sometimes we want to test if one condition is true or false. For example, IF Sarah > 16, then she can learn to drive ELSE she is too young to drive

  4. …a decision-making step. Condition? Yes No False Block True Block

  5. In PYTHON, what is the SYNTAX for the IF statement? if<condition>: <block of code executed if true> else: <block of code executed if false> Name='Sydney' if len(Name)>15: print('You have a long name!') else: print('You have a short name!') An example of PYTHON IF Statement Syntax

  6. Task 1 • Create a program that prompts the user for their age • If their age is less than 14 it should produce a simple • funny statement • 3) If their age is greater than or equal to 14, it should produce a • different statement • 4) Create your program in SCRIPT mode and save it as Simple • If Statement

  7. Task 2 • Create a program that prompts the user for their NAME and the YEAR • they were born. • If their year is after 1999, the program should output • ‘Welcome NAME, you are a 21st Century Child!’ • 3) If their year is not after 1999, the program should output • ‘Welcome NAME, you are a 20th Century child!’ • 4) Create your program in SCRIPT mode and save it as Simple • If Statement 2

  8. Task 3 • Create a program that prompts the user for a PASSWORD • If the entered password is less than 8 characters long, it should output • ‘Password Rejected.’ • 3) If the entered password is at least 8 characters long, it should output • ‘Password Accepted.’ • 4) Create your program in SCRIPT mode and save it as Simple • If Statement 3