Posts by WhoisMatt • 382 points
20 posts
-
0
votes2
answers682
viewsA: How to count how many odd numbers there are between -999 and 0
This is a basic exercise, practice. c = 0 for i in range(-999, 0): if i % 2 != 0: c += 1 print(c) ########OUTPUT######## 500…
-
0
votes2
answers63
viewsA: How do I show the already used and wrong letters in the hangman game? and leave the word on the bar in maiscula?
I made a code that seems to work. I commented on the parts that answer your question. Follows the code: #! python3 print(""" ####################### # Jogo da forca # ####################### """)…
-
0
votes2
answers427
viewsA: python 3, exercise with prime numbers
I believe this is a valid solution to your problem: import math def fast_prime(numero): """Função de retorno rapido de números primos""" if numero == 1: return False if numero == 2: return True if…
-
3
votes2
answers101
viewsA: Doubt about mod
Let’s think about basic math: If you take the results 12 and divide it by 18, as you would? Well, I guess everybody here knows how to do a division account so let’s go. 12 |18 - 0 0 12 Okay. After…
-
1
votes4
answers361
viewsA: Python Code - Conditional Structure
If you want a simple code without having so many checks you can simply use this code: sal = float(input('Insira o salário: ')) vendas = float(input('Insira o valor de vendas: ')) while True: if sal…
-
3
votes2
answers59817
viewsA: error: failed to push some refs
Your local repository is not compatible with the online repository. First of all: remove the files modified by you and put them in any directory. After this is done run the command: git remote…
-
0
votes1
answer139
viewsA: How to download an image using Pillow(python)
You can use the module os to choose the location where you want to save the file as follows: from os.path import join as pjoin from PIL import Image filename = "arquivo.png" i =…
-
0
votes1
answer157
viewsA: Python3 in module named tld
How is the version of python3 you must use the following command: $ python3 -m pip install tld
python-3.xanswered WhoisMatt 382 -
-1
votes2
answers191
viewsA: difference between vet[] and *vet
Your question is whether there’s a difference between vet[] and *vet. Well, the answer is no. According to the booklet IME USP: Vectors Vectors are indexed structures used to store data of the same…
-
1
votes2
answers401
viewsA: How to display text with multiple lines with format?
Today with the python3 version you can use the fstrings as follows: a = input("Digite algo: ") print(f""" Você digitou: {a} O texto possui {len(a)} caracteres O texto é um valor numérico?…
-
1
votes3
answers1665
viewsA: Doubt in percentage in C
Your formula for the discount calculation is wrong, in this case, as you want to discount the value you need to subtract the price by multiplying the price by the percentage value. Then your code…
-
0
votes3
answers5171
viewsA: Remove string quotes in array
If you use the replace as friends indicated is not your intention you can also use regular expressions using the function sub module re. In case your code would look like this: print('lista --->…
-
0
votes1
answer244
viewsA: Python error in Def _init_ function when creating a Chatbot
Remove the part of the third line where there is bot.def __init__(self, nome_bot): This syntax is wrong, see.…
-
0
votes2
answers150
viewsA: Regular expression validation is invalid even when you find a match
Try to use these regex: def __validaEmail(self, email): result = re.match(r'''( [a-zA-Z0-9,_%+-]+ # username @ # @ simbol [a-zA-Z0-9.-]+ # domain name (\.[a-zA-Z]{2,4}){1,2} # dot-something )''',…
-
1
votes2
answers61
viewsA: Pass X function as parameter to Y function, but only define X parameter within Y
One way to do this is this:: def f_numbers(number=True): if number: return 'Seu número: '+ f'{number}' else: return 'Você não definiu um número' def func2(f_numbers): number = <Aqui você digita…
-
2
votes2
answers2474
viewsA: error to import pandas library and numpy
One way to find out what the problem is first is to know if you have these modules installed. First use the command: $ pip3 list This command will list all modules installed on your machine. You…
-
2
votes1
answer100
viewsA: Syntax error in a beast program in Python
From what I’m seeing your code has a number of errors: Identation: when you use one if, the next line must contain 4 spaces in relation to the top line. When calling the function if and its…
-
1
votes2
answers105
viewsA: How to perform a function several times simultaneously?
One way to do this is simply by multiplying the amount of "hi’s" by the number of processes: from time import sleep def oi(num_process): while True: print('oi\n' * num_process) sleep(1) oi(3) The…
-
0
votes3
answers1736
viewsQ: Find word in python txt file
I have a program called anagrams.py and its function is to show the permutations of a word typed by the user if it is in the file words.txt. This is the complete code: """ Anagrams by WhoisBsa """…
-
1
votes1
answer42
viewsQ: Email and Password continue to appear even after creating an SSH key
I created a key SSH to use on Github and even following all the steps that were the following: I used the command: ssh-keygen -t rsa -b 4096 -C "[email protected]" Then I used the command cat:…