Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- from random import randint
- chand = sqlite3.connect("computer_cards.db")
- #This function reads all the cards from the d/B
- def read_all_cards():
- sql_all = "SELECT * FROM computer"
- result = chand.execute(sql_all)
- return result.fetchall()
- #This function picks a random card
- def pick_card():
- cards = read_all_cards()
- random_card = cards[randint(0, len(cards) - 1)]
- return random_card
- #Now we can call these functions
- print('*******************************')
- print('WELCOME TO THE RANDOM CARD GAME')
- print('*******************************')
- print('')
- card = pick_card()
- print('Your random card is',card)
- first=card[0]
- print('Your computer is called:',first)
- chand.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement