I wrote how to use if for each pattern. I also referred to the example using multiple functions. The conditional expression structure contains the necessary lack of knowledge.
for n in range(2,10):
for x in range(2,n):
if n % x == 0:
print(n,'equals',x,'*',n//x)
break
else:
print(n,'is a prime number')
In addition, the code under the condition of specifying the numerical value is as follows.
x = 25 //Specify a number
if x < 0:
print('negative')
elif x ==0:
print('zero')
elif x ==10:
print('ten')
elif x ==50:
print('fifty')
elif x ==25:
print('twenty-five')
else:
print('positive')
"""Determine the conditions for the branch point from else
print('Condition name')
"""
Recommended Posts