Questions tagged as 'python-3.x'

2
answers

Problem using Switch Case in Python 3

print ("ESCOLHA A CERVEJA PELO NUMERO") print ("1-ANTARTICA R$6.00;2-SKOL R$6.50;3-BRAHMA R$8.20;4-SOL R$8.25;") cerveja = input ("5-NORTENHA R$16.80;6-PROIBIDA R$4.80;7-DEVASSA R$5.90;8-HEINEKEN R$9.00") q = float(input("Quantas ???")) def cas...
asked by 26.10.2015 / 05:30
2
answers

How to break the line?

Nome = input("Digite o nome do cliente: ") DiaVencimento = input("Digite o dia de vencimento: ") MêsVencimento = input("Digite o mês de vencimento: ") ValorFatura = input("Digite o valor da fatura: ") print("Olá,", Nome, "A sua fatura com venci...
asked by 26.04.2017 / 20:44
3
answers

if and else with almost equal blocks

In Python, suppose I have a function: def func(x): if x%2 == 0: j = x/2 print(j) else: j = x print(j) Do not mind the logic of the code, it's just a simple example. The blocks of if and else are...
asked by 02.05.2018 / 05:12
1
answer

Is there any way to exclude the automatic space that appears after the comma in python?

A brief example: zero = 0 print('exemplo',zero) The program shows:    example 0 I wanted without the space:    example0     
asked by 26.09.2017 / 11:25
2
answers

Change string to uppercase and remove whitespace

I'm trying to make a program in Python 3 that should turn typed text into uppercase and remove white space. I would like to know what is wrong with my code since it is not deleting the blanks. I tested two codes. First code: print ("-"*50...
asked by 31.10.2018 / 12:02
1
answer

How can I make sure the word does not break in the middle? And leave a maximum of 40 characters per line?

valor = '''In the beginning God created the heavens and the earth. Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters. And God said, "Let there be light," and ther...
asked by 10.10.2018 / 15:49
2
answers

How can I compare the keys of a hash with a user input?

File: 101;Johnny 'wave-boy' Jones;USA;8.32;Fish;21 102;Juan Martino;Spain;9.01;Gun;36 103;Joseph 'smitty' Smyth;USA;8.85;Cruizer;18 104;Stacey O'Neill;Ireland;8.91;Malibu;22 105;Aideen 'board babe' Wu;Japan;8.65;Fish;24 106;Zack 'bonnie-lad' M...
asked by 28.01.2017 / 03:41
1
answer

How to save a video captured by webcam without showing it using OpenCV in python?

I'm starting to learn Computer Vision. I'm using the OpenCV module for Python 3. Reading tutorials, I discovered the following script: import cv2 cap = cv2.VideoCapture(0) fourcc = cv2.VideoWriter_fourcc(*'DIVX') out = cv2.VideoWriter('outpu...
asked by 15.01.2017 / 17:24
1
answer

Check if all items in a string are different?

How can I check if all items in a string are different? For example: x:"abcdefga" = False y:"abcdefg" = True Since x[0] == x[7] , then it would be False . But in this case I would use this condition in if . Is th...
asked by 02.05.2017 / 01:37
1
answer

Data structure that represents a deck of cards

I'm developing a project in Python where I have to play a card game. I am doubtful as to what the best data structure to use, according to the description provided: Each letter must be represented by a pair (,), in which both elements are str...
asked by 07.12.2017 / 14:05