samedi 13 juin 2020

Please help me , why my function and the print statements is not working

When squirrels get together for a party, they like to smoke cigars.

A squirrel party is successful when there were between 40 and 60 (both inclusive) cigars, unless it is weekend when there is no upper limit on the number of cigars.

Write a function cigar_party() that determines whether the party was successful or not.

The function must receive as parameters an integer value for the number of cigars as well as an integer value to indicate a weekend. The function must then determine if it was a successful party or not and return a true (1) or a false (0) value (true for successful and false for unsuccessful) to the calling statement in the main program.

Complete the Python program by asking the user to enter the number of cigars and indicate whether it is weekend or not. After that, the program must call the cigar_party() function with the values entered by the user.

This is what I have done:

cigars=int(input("Enter the number of cigars: "))
is_weekend=int(input("Is it weekend? 1=True, 0=False: "))

def cigar_party(cigars, is_weekend):
  if is_weekend and cigars >= 40:
      return True
      print("Yes! It was a successful cigar party!!!")
  elif cigars >= 40 and cigars <= 60:
      return True
      print("Yes! It was a successful cigar party!!!")
  else:
    return False
print("No, it was a disappointing cigar party...)

Aucun commentaire:

Enregistrer un commentaire