Answer to Question #290539 in Python for H A

Question #290539
question 1)  input gender, age: old enough for army (age+male) by using AND

question 2) input if student took swe234, ddf160, bty123, Ptr223: if took any of    them, then finished Group C by using OR

question 3)Loops:
for:  15..20, 10..1, evens 2..20; print 1..10 on 1 line 

question 4) sum of the evens
question 5) sum of the odds
question 6) find the max
question 7) find the min
question 8) input 5 numbers and calculate

I want very simple code
1
Expert's answer
2022-01-25T13:24:30-0500


question 1)
Answer:
gender=input("Input gender: ")
age=int(input("Input age: "))
if(gender=="male" and age>=18):
    print("Old enough for army")
else:
    print("Not old enough for army")
    


question 2)
Answer:


groups =["swe234", "ddf160", "bty123", "Ptr223"]
group=input("Input group: ")


if(group in groups):
    print("Group is: "+group)
else:
    print("Group C")
    




question 3)
Answer:
for i in range(15,21):
    print(i,end=" ")
print()
for i in range(10,0,-1):
    print(i,end=" ")
print()
for i in range(2,21):
    print(i,end=" ")
print()
for i in range(1,11):
    print(i,end=" ")


question 4-8)
Answer:


sumEvens=0
sumOdds=0
maxNumber=0
minNumber=1000000


for i in range(0,5):
    number=int(input("Enter number: "))
    if number %2==0:
        sumEvens+=number
    else:
        sumOdds+=number
    if number>maxNumber:
        maxNumber=number
    if number<minNumber:
        minNumber=number
    
print(f"Sum of the evens: {sumEvens}")
print(f"Sum of the odds: {sumOdds}")
print(f"The max: {maxNumber}")
print(f"The min: {minNumber}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS