grandfathermagic

בדיקה לוגית

Apr 17th, 2020
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.28 KB | None | 0 0
  1. code = "4812"
  2.  
  3.  
  4. def is_4_is_in_string(user_input):
  5.     if "4" in user_input:
  6.         print("True 4")
  7.         return True
  8.     else:
  9.         print("False 4")
  10.         return False
  11.  
  12.  
  13. def is_8_is_in_string(user_input):
  14.     if "8" in user_input:
  15.         print("True 8")
  16.         return True
  17.     else:
  18.         print("False 8")
  19.         return False
  20.  
  21.  
  22. def is_1_is_in_string(user_input):
  23.     if "1" in user_input:
  24.         print("True 1")
  25.         return True
  26.     else:
  27.         print("False 1")
  28.         return False
  29.  
  30.  
  31. def is_2_is_in_string(user_input):
  32.     if "2" in user_input:
  33.         print("True 2")
  34.         return True
  35.     else:
  36.         print("False 2")
  37.         return False
  38.  
  39.    
  40. def test_if_4_but_not_others(user_input):
  41.     if is_4_is_in_string(user_input) and not is_1_is_in_string(user_input) and not is_2_is_in_string(user_input) and not is_8_is_in_string(user_input):
  42.         return True
  43.     else:
  44.         return False
  45.  
  46.    
  47. def test_if_8_but_not_others(user_input):
  48.     if is_8_is_in_string(user_input) and not is_1_is_in_string(user_input) and not is_2_is_in_string(user_input) and not is_4_is_in_string(user_input):
  49.         return True
  50.     else:
  51.         return False
  52.    
  53.    
  54.  
  55.    
  56. def test_if_2_but_not_others(user_input):
  57.     if is_2_is_in_string(user_input) and not is_1_is_in_string(user_input) and not is_8_is_in_string(user_input) and not is_4_is_in_string(user_input):
  58.         return True
  59.     else:
  60.         return False
  61.    
  62.    
  63.    
  64.    
  65.  
  66.    
  67. def test_if_1_but_not_others(user_input):
  68.     if is_1_is_in_string(user_input) and not is_2_is_in_string(user_input) and not is_8_is_in_string(user_input) and not is_4_is_in_string(user_input):
  69.         return True
  70.     else:
  71.         return False
  72.    
  73. def test_if_two_numbers(user_input):
  74.    
  75.    
  76.    
  77.    
  78.    
  79.                
  80. def logic_test(user_input):
  81.     if test_if_4_but_not_others(user_input) or test_if_8_but_not_others(user_input) or test_if_2_but_not_others(user_input) or test_if_1_but_not_others(user_input)  == 1:
  82.         print("you have one key")
  83.     elf test_if_two_numbers(user_input)
  84.         print("this is an else statment")
  85.         return "notgood"
  86.  
  87.  
  88.  
  89. #this_is_my_input = input("enter your 4 digit code")
  90. this_is_my_input = "4000"
  91. logic_test(this_is_my_input)
Advertisement
Add Comment
Please, Sign In to add comment