Questions tagged as 'python'

2
answers

How do I check if it is uppercase, lowercase, or mixed with upper case?

print('-----') print('TESTE') print('-----') print() lista = ['Joao', 'Joaozinho', 'Rafael'] print(lista) var = str(input('Digite algum dos nomes da lista:')) if var == 'Joao' or var == 'João' or var == 'joao' o...
asked by 25.02.2017 / 02:02
3
answers

Get source file from a Python module

How can I assign a method to a module in Python or even access the source file of this module? I tried using the __file__ attribute, as shown below, but returned the error saying that the module does not have such an attribute. >>...
asked by 18.02.2017 / 01:59
1
answer

Turn all elements of a list into floats

This is the code I wrote. n_alunos=input('') x=0 idades=[] alturas=[] while x != n_alunos: x+=1 n=raw_input('') a=n.split(" ") idades.append(a[0]) alturas.append(a[1]) How do I transform the elements of the 2 string lis...
asked by 19.11.2017 / 23:27
3
answers

Simple question about the title () command

If I put for example the name:    roberto fair da silva using title it looks like this:    Roberto Justo Da Silva How do I make the command title do not modify the word 'da' to look like this:    Roberto Justo da S...
asked by 07.10.2018 / 22:36
1
answer

Problem with IF conditional structure

I'm trying to learn Python (and programming in general). At the moment, I'm studying if and else and conditions and, or and not. I'm training by doing a quiz about star wars, but I'm having a hard time. Score = 0 Resposta1 = input("No filme S...
asked by 10.12.2018 / 14:40
3
answers

Repeat if again when validation fails

ConvInicial = str(input('Você: ')) if ConvInicial == 'Não estou passando bem' or ConvInicial == 'Estou com dor' or ConvInicial == 'Preciso de ajuda': print('O que você está sentindo?') RespDor = input('Você: ') if RespDor == 'Estou com dor de ca...
asked by 13.10.2018 / 23:02
2
answers

Why is the variable unchanged?

I have the following code below: #!/usr/bin/python3 # VARIÁVEIS variavel = 0 def valores(): if ( variavel == 0): variavel = 100 elif (variavel == 1): variavel = 200 elif (variavel == 2): variavel = 3...
asked by 26.02.2018 / 20:00
2
answers

Why divide this operation into two causes change in result?

I made a simple algorithm that solved Fibonacci in 2 logical operations inside the loop. I decided to look for a better way and found a version that does in only 1 calculation in of the loop. It worked perfectly, but when I went to understand...
asked by 20.02.2018 / 03:01
4
answers

Sum of each element of two lists

There is some code that adds the elements of two lists, for example: A=[1,2,3,4] B=[2,4,5,6] D=[3,6,8,10] # o elemento 3 e a soma dos elementos 1 e 2 da lista A e B     
asked by 23.06.2018 / 00:27
2
answers

Datetime without the year

I need to represent holidays and in my holiday class I need to set the start date and end of the holiday. As the start and end date I need to enter only the month, day, hour and minute . But the datetime class of python requires that the year...
asked by 25.05.2018 / 16:21