Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ตัวอย่างข้อสอบ Computer Programming ข้อที่ 2
- #Part 1
- num=int(input("Enter a number (10-99): "))
- while num<10 or num>99:
- print("Invalid number!")
- num=int(input("Enter a number (10-99): "))
- #Part 2
- num_str=str(num)
- first_str=num_str[0]
- second_str=num_str[1]
- a=int(first_str)
- b=int(second_str)
- print(f"""a = {first_str} and b = {second_str}\n""")
- if a>5 and b>5: #a>5
- print("""Less than 5 = 0
- Equal to 5 = 0
- More than 5 = 2""")
- if a>5 and b==5:
- print("""Less than 5 = 0
- Equal to 5 = 1
- More than 5 = 1""")
- if a>5 and b<5:
- print("""Less than 5 = 1
- Equal to 5 = 0
- More than 5 = 1""")
- if a<5 and b<5: #a<5
- print("""Less than 5 = 2
- Equal to 5 = 0
- More than 5 = 0""")
- if a<5 and b==5:
- print("""Less than 5 = 1
- Equal to 5 = 1
- More than 5 = 0""")
- if a<5 and b>5:
- print("""Less than 5 = 1
- Equal to 5 = 0
- More than 5 = 1""")
- if a==5 and b>5: #a==5
- print("""Less than 5 = 0
- Equal to 5 = 1
- More than 5 = 1""")
- if a==5 and b==5:
- print("""Less than 5 = 0
- Equal to 5 = 2
- More than 5 = 0""")
- if a==5 and b<5:
- print("""Less than 5 = 1
- Equal to 5 = 1
- More than 5 = 0""")
- '''
- #Tools
- print(first_str, second_str, sep='/')
- print(first_int, second_int, sep='/')
- '''
Add Comment
Please, Sign In to add comment