Condition Program Day1 (If Condition)
Condition Program Day1 (If Condition)
--------------------
These are used to infused at a runtime and this can be done in 3 ways.
'''
# s="my name is %s and i am %d years old"%('karthik',15)
# print(s)
# here we can use outside variable directly into the string instead of pass them as
a argument.
#boundary is { }
# when you are using f literals you need to add a letter "f" before the string
starts.
# a="karthik"
# b=20
# print(f"hello guys i'm {a} and i'm {b} years old")
-----------------------------------------------------------------------------------
------------------------------------------------------------------
flow control
statements:
2.if-else
3.elif
4.nested if-else
1.simple if:
************
*if condition become True "if block/True State Block" will get execute else it will
just go with flow of program execution.
OR
*if the given condition become True it will execute in True state block state and
if the given condition is not satisfied just it will retun none
syntax:
*******
if cond:
stmt1 }
stmt2 }---> TSB/if block
stmt3 }
NOte:-->
drawback of simple-if:
**********************
*if cond is False we dont have any specific block of code to execute, to over this
we go "if-else"
"""
#3.wap to check if the student has scored 70% print "good luck "(take user input)
a=98
b=67
if a>b:
print(f'here {a} value is greater than {b}')
# # 12.wap to check the given string is uppercase or not (take user input)
# OR
#14.wap to display "Python Coding" if the number is greater than 1 and lessthan 5
(take user input)
#15.wap to check whether given number is negative and print "its negative guys"
#17.wap to check whether the given number is even or not,if even store the value
inside the list (take user input)
#19.wap to check whether a given value is divisible by 5 and 7,if the value is
divisible then display the square of the values (take user input)
#20.wap to check whether a given value is present in between 45 and 200 and the
number should be divisible by 4 and 5 ,if satisfied,display the ascii chracters
(take user input)
string="hello world"
sub_string="world"
if sub_string in string:
print("yes its present")
l1=[1,5,3,9,12]
print(max(l1)) #----->12
print(min(l1)) #----->1
l2=[1,5,3,9,2]
b=l2.index(max(l2))
print(b)
l3=[11,12,1,31,31,"hero","hero"]
print(set(l3))
l4=[1,2,3,4,2,2,2,7,8,5]
s=l4.count(2)
print(s)
assignment question
assignment question
assignment question