Subscribe this Blog

Wikipedia

Search results

Notifications and New Posts!

Saturday, October 24, 2020

YouTube Premiered Lecture - October 24, 2020, 5:00 PM - ADVANCED PROGRAMMING CONCEPTS - Python (TY A and B)

 ADVANCED PROGRAMMING CONCEPTS - Python

Saturday, 24 October17:00 – 18:00
Weekly on Saturday, until 30 Nov 2020
Description: Subject : ADVANCED PROGRAMMING CONCEPTS - Python To solve assignments Please join Google Classroom. Invitation of Google Classroom has been sent to your official email id. Please accept the google classroom invitation through official email id. Or directly by entering Class code of Google Classroom also you can join Google Class room to solve assignments. Class code of Google Classroom : 3ojdsjm
Organiser: Sachin Bhosale

Due to internet/network connectivity issue, We will be conducting lecture on YouTube today. 
Lecture will start at sharp 05:00 pm today. Please attend it. And if you have any questions then
please ask in Comment box below the video. Please co-operate and give your feedback to video.


YouTube Video Lecture: This video is premiered it will start at sharp 05:00 pm today.


Python Programs:
# Python Conditions and If statements
#
# Equals: a == b
# Not Equals: a != b
# Less than: a < b
# Less than or equal to: a <= b
# Greater than: a > b
# Greater than or equal to: a >= b

a = 33
b = 200
# if b < a:
#   print("b is greater than a")
#
# print("Welcome")

if (b > a):
  print("b is greater than a")
Output:
b is greater than a

#Indentation Issue
a = 33
b = 200
if b > a:
print("b is greater than a") # you will get an error
Output:

  File "C:/Users/Hp/PycharmProjects/Python_if_statements/2.py", line 5
    print("b is greater than a") # you will get an error
    ^
IndentationError: expected an indented block

# elif
# The elif keyword is pythons way of saying
# "if the previous conditions were not true, then try this condition".

a = 33
b = 33
if b > a:
  print("b is greater than a")
elif a == b:
  print("a and b are equal")
Output:
a and b are equal

# else
# The else keyword catches anything which isn't caught by the preceding conditions.

a = 33
b = 33
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:
a and b are equal

#You can also have an else without the elif:
a = 333
b = 333
if b > a:
  print("b is greater than a")
elif b<a:
  print("b is not greater than a")
else:
  print("Both a and b are equal")
Output:
Both a and b are equal

# Short Hand If
# If you have only one statement to execute,
# you can put it on the same line as the if statement.

a=10
b=1

if a > b: print("a is greater than b")
Output:
a is greater than b

#Short Hand If ... Else

a = 2
b = 330
print("A") if a < b else print("B")

#This technique is known as Ternary Operators, or Conditional Expressions.
Output:
A

#One line if else statement, with 3 conditions:

# a = 331
# b = 330
# print("A") if a > b else print("=") if a == b else print("B")

# a = 330
# b = 330
# print("A") if a > b else print("=") if a == b else print("B")


a = 330
b = 333
print("A") if a > b else print("=") if a == b else print("B")

Output:
B


No comments:

Post a Comment