เราจะดึงตัวเลขจากการ Random ของข้อ 1 มาใช้ในข้ออื่นยังไงครับ

ช่วยชี้แนะหน่อยครับ ลองผิดลองถูกจนงงแล้วครับ

https://imgur.com/ZE5oys0

while True:
  print("*** Menu ***")
  print("1. Random Data to 10 element")
  print("2. Bubble Sort")
  print("3. Insertion Sort")
  print("4. Shell Sort")
  print("0. Exit")
  choice = input("Enter Choice : ")
  if choice == "1":
    import random
    for i in range(10):
      c = random.randint(0,50)
      print("Random Element = ",c)
  elif choice == "2":
    bubble_sort(arr)
    print(arr)
  elif choice == "3":
    insertion_sort(arr)
    print(arr)
  elif choice == "4":
    shell_sort(arr)
    print(arr)
  elif choice == '0':
    print("Exiting...")
    break
  else:
    print("Invalid choice. Enter a number between 0 and 4.")
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่