Advertisement
Prof_Carvalho

Untitled

Mar 23rd, 2022
1,590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import requests
  2. # url = 'https://viacep.com.br/ws/09051110/json'
  3. # resposta = requests.get(url)
  4. # print('Código de Resposta:', resposta.status_code)
  5. # dados = resposta.json()
  6. # print('Nome da rua:', dados["logradouro"])
  7. #Bot jogador de 21
  8. #Pede um baralho
  9. import random
  10. fator_de_seguranca = random.randint(0,4)
  11. resposta = requests.get('https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1')
  12. deck_id = resposta.json()["deck_id"]
  13. mao = 0
  14. tabela_conversao = {'2':2, '3':3, '4':4, '5':5, '6':6, '7':7,
  15.                    '8':8, '9':9, 'ACE':1, 'QUEEN':10,
  16.                    'KING':10, 'JACK':10, '10':10}
  17. while mao < (21 - fator_de_seguranca):
  18.   resposta = requests.get(f'https://deckofcardsapi.com/api/deck/{deck_id}/draw/?count=1')
  19.   valor = resposta.json()['cards'][0]['value']
  20.   mao = mao + tabela_conversao[valor]
  21.   print('Carta Sorteada:', valor)
  22.   print('Total da Mao:', mao)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement