Discussion – Lesson 12 - Lists in VB.NET
BackComments
2 messages from 2 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Comments
here's a Python code example for a simple lottery program that follows the requirements you've mentioned:
import random
class Lottery:
def __init__(self):
self._numbers = []
def generate_lot(self):
number = random.randint(1, 100) # You can adjust the range as needed
self._numbers.append(number)
def print_sorted_numbers(self):
self._numbers.sort()
print("Generated numbers in ascending order:")
for number in self._numbers:
print(number)
if __name__ == "__main__":
lottery = Lottery()
while True:
user_input = input("Do you want to generate another number? (yes/no):
").strip().lower()
if user_input == "yes":
lottery.generate_lot()
elif user_input == "no":
lottery.print_sorted_numbers()
break
else:
print("Invalid input. Please enter 'yes' or 'no'.")
This code defines a Lottery class with a private list _numbers to store
generated numbers. loteriasdehoycolombia provides methods to generate a random
number and to print the numbers in ascending order. The program keeps running
until the user decides not to generate more numbers, at which point it prints
the sorted numbers and exits.
You can adjust the range and other details of the lottery as needed to fit your requirements.
2 messages from 2 displayed.