Computer Science, asked by zahamariyam13, 2 months ago

true or false
looping allows the program to check for certain conditions that need to met in order to execute it

Answers

Answered by Anonymous
2

Answer:

Explanation:

n order to write useful programs, we almost always need the ability to check conditions and change the behavior of the program accordingly. Conditional statements give us this ability. The simplest form is the if statement, which has the genaral form:

if BOOLEAN EXPRESSION:

   STATEMENTS

A few important things to note about if statements:

The colon (:) is significant and required. It separates the header of the compound statement from the body.

The line after the colon must be indented. It is standard in Python to use four spaces for indenting.

All lines indented the same amount after the colon will be executed whenever the BOOLEAN_EXPRESSION is true.

Here is an example:

food = 'spam'

if food == 'spam':

   print('Ummmm, my favorite!')

   print('I feel like saying it 100 times...')

   print(100 * (food + '! '))

The boolean expression after the if statement is called the condition. If it is true, then all the indented statements get executed. What happens if the condition is false, and food is not equal to 'spam'? In a simple if statement like this, nothing happens, and the program continues on to the next statement.

Run this example code and see what happens. Then change the value of food to something other than 'spam' and run it again, confirming that you don’t get any output.

Flowchart of an if statement

_images/flowchart_if_only.png

As with the for statement from the last chapter, the if statement is a compound statement. Compound statements consist of a header line and a body. The header line of the if statement begins with the keyword if followed by a boolean expression and ends with a colon (:).

The indented statements that follow are called a block. The first unindented statement marks the end of the block. Each statement inside the block must have the same indentation.

Indentation and the PEP 8 Python Style Guide

The Python community has developed a Style Guide for Python Code, usually referred to simply as “PEP 8”. The Python Enhancement Proposals, or PEPs, are part of the process the Python community uses to discuss and adopt changes to the language.

PEP 8 recommends the use of 4 spaces per indentation level. We will follow this (and the other PEP 8 recommendations) in this book.

To help us learn to write well styled Python code, there is a program called pep8 that works as an automatic style guide checker for Python source code. pep8 is installable as a package on Debian based GNU/Linux systems like Ubuntu.

In the Vim section of the appendix, Configuring Ubuntu for Python Web Development, there is instruction on configuring vim to run pep8 on your source code with the push of a button.

4.1.2. The if else statement

It is frequently the case that you want one thing to happen when a condition it true, and something else to happen when it is false. For that we have the if else statement

Answered by rashidnafishamm
1

Answer:

looking allows the program to check for certain conditions that need to met in order to execute it is true

Similar questions