100% satisfaction guarantee Immediately available after payment Read online or as PDF No strings attached
logo-home
PYTHON & SQL $12.49
Add to cart

Flashcards

PYTHON & SQL

Preview 8 out of 15  Flashcards

EXPLAIN IF STATEMEN?
EXPLAIN IF STATEMEN?
•It uses the if keyword, followed by the condition. •Syntax: if condition: #statement to execute if the condition is true Example: #if condition num = int(input("enter the number")) if num >10 : print("Number is greater than 10") Output: enter the number 11 Number is greater than 10 If-Else Statement •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. Syntax: •The syntax of the if...else statement is − if expression: statement(s) else: statement(s) Example: •#if-else condition age = int (input("Enter your age ")) if age>=18: print("You are eligible to vote !!") else: print("Sorry! you have to wait !!") Output: Enter your age 15 Sorry! you have to wait !! Elif Statement •The elif statement allows you to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE. Syntax: if expression1: statement(s) elif expression2: statement(s) elif expression3: statement(s) else: statement(s) • Example: a = int(input(“Enter the first number”)) b = int(input(“Enter the second number”)) if b > a: print("b is greater than a") elif a == b: print("a and b are equal") else: print("a is greater than b") Output: Enter the first number10 Enter the second number12 b is greater than a The pass Statement •If statements cannot be empty, but if for some reason you have an if statement with no content, put in the pass statement to avoid getting an error. Example: a = 33 b = 200 if b > a: pass
0
8
Flip
avatar-seller

The benefits of buying summaries with Stuvia:

Created by fellow students, verified by reviews

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Techn028. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

47251 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 16 years now

Start selling

Recently viewed by you


$12.49
  • (0)
Add to cart
Added