Online Safety Community

If you have knowledge of other programming languages, then you would know the importance of conditional statements. Conditional statements are required for taking decisions. Whenever we operate the software, our choice of action decides the next step. A simple example is booking an air ticket. If you want to travel in economy class, you will be presented a different package, whereas if you opt for business class you will be given a different package. So, let’s take a look at the conditional statements available in python.

-An else statement can be combined with an if statement. An else statement contains the block of code that executes if the conditional expression in the if statement resolves to 0 or a FALSE value.

Format:

if (expression): code1  else:  code2

EXAMPLE:

a= 7 b=8 if(a>b): print ‘I am greater than b’ else: print ‘I am greater than a’

Output :I am greater than a

-To check multiple conditions and run the block of code for the condition that returns ‘true’

Format:

if expression1: code1  elif expression2: code2  elif expression3: code3  else:  code4

EXAMPLE:

a=7 b=7 if(a>b): print ‘I am greater than b’ elif (b>a): print ‘I am greater than a’ elif (a==b): print ‘Hey!! we both are equal’

Output: Hey!! we both are equal

- A simple if statement can be used without any else or else if. Usage of simple if statement means that the lines of code should be executed only if the condition is true.

Format:

if condition : execute the code

EXAMPLE:

a=7 b=7 if(a>b): print ‘I am greater than b’ print ‘Good Bye’

Output: Good Bye

HTTPS://DOCS.PYTHON.ORG/2/LIBRARY/THREADING.HTML#CONDITION-OBJECTS

Views: 62

Reply to This

Replies to This Discussion

Head scratching - I signed up here thinking I may gain knowledge of safety issues

RSS

Take our poll!

Take our poll!

Latest Activity

Larry Labelle is now a member of Online Safety Community
1 hour ago
Nakul Pratap posted a blog post

Nebosh Course in Mumbai | Safety Course in Mumbai

This Nebosh International Typical Certification focuses on with how Safety and health management can be forced within the corporation. This training course can be especially made for supervisors, inspector and also staff representatives to handle chance efficiently. This concentrate internationally requirements and also supervision techniques, meet the requirements college students throughout conventional area for you to proficiently perform this safety and health process. This IGC can be…See More
10 hours ago
Mark Nilson posted events
10 hours ago
Training Doyens posted an event
Thumbnail

Strategic Planning and Execution: The 1-2-3 Year Plan for Enterprise Success and Organizational Benefit – Training Doyens at 26468 E Walker Dr, Aurora, Colorado 80016

September 11, 2018 from 1pm to 2:30pm
OVERVIEWHave you looked at how your company develops strategy lately?Is your organization poised to implement strategies that create value, generate growth and result in profits? Who thinks strategically in your firm? Strategy formation and strategic thinking have evolved; make sure your…See More
12 hours ago

Forum

5 TECHNOLOGY-BASED LONE WORKER SAFETY SOLUTIONS

ABOUT 75% OF EMPLOYEES IN NORTH AMERICA ARE MOBILE WORKERS. ADVANCES IN COMMUNICATIONS TECHNOLOGY MEANS THESE WORKERS CAN WORK ANYWHERE AT ANY TIME. THESE NEW TECHNOLOGIES ALSO MEAN THESE MOBILE…Continue

Tags: Solutions, People, IoT, Monitoring, Remote

Started by Jen McDade May 31.

Road Safety Solutions 14 Replies

The Road Safety Signs ,Barriers,Humps,Hazard Markers and Visual Warnings are some of the important marks to be observed. Signs such as "keep left",stop, "give way" should not be casually treated.…Continue

Tags: safety, gear, wear, Equipment, &

Started by Enna Henry. Last reply by Jen McDade May 31.

Remote Monitoring

Get "Safe Assets and Sound Productivity" Through Remote Monitoring.Visit:…Continue

Tags: Solutions, People, IoT, Monitoring, Remote

Started by Jen McDade May 23.

Python Condition Objects Tutorial in 2018 1 Reply

If you have knowledge of other programming languages, then you would know the importance of conditional statements. Conditional statements are required for taking decisions. Whenever we operate the…Continue

Tags: course, certification, training, languages, programming

Started by Elena Lauren. Last reply by Jim Chesters May 15.

Power BI Visualization Types

Visualizations in Power BI displays the visual insights from a data. In power bi service a visual can be pinned from reports to create dashboards. Visuals are used in reports.List of visualizations…Continue

Tags: COURSE, TRAINING, BI, POWER

Started by Azharuddin May 15.

Badge

Loading…

© 2018   Created by Safety Community.   Powered by

Badges  |  Report an Issue  |  Terms of Service