Questions tagged as 'python'

2
answers

Is it possible to use dictionaries within lists in Python?

I need to go through a list that contains dictionaries and display the information for it. But testing here the attributes .item() and .value() could not. See: #6.8 - Animais de Estimação: Pets = [{'Zeus':{'Tipo':'Gato','Dona':'...
asked by 20.11.2018 / 18:06
2
answers

How to declare an anonymous function in Python?

How do I declare and how does an anonymous function of Python work?     
asked by 12.02.2015 / 11:58
2
answers

Accept only numeric input

nota = -1 while nota < 0 or nota > 10: nota = int(input("Informe a nota entre 0 e 10: ")) if nota < 0 or nota > 10: print("Valor inválido") I need to include in this validation code for, if the user types string (a,...
asked by 09.10.2017 / 21:28
3
answers

How to join several dictionaries in Python?

In some languages, you can join objetos/array to one. For example, in PHP, I can join multiple arrays like this: $userInfo = ['name' => 'Wallace'] $jobInfo = ['job' => 'Developer'] $ageInfo = ['age' => '26'] $info =...
asked by 16.11.2016 / 13:03
2
answers

Use "ping" on a site with Python

In Windows CMD, you can use the ping command to get IP from certain sites, for example: ping www.facebook.com.br Is there any way to do something similar using Python 3.4?     
asked by 24.07.2014 / 00:24
2
answers

How to make a range with alphabet letters in python?

In PHP, when we want to do array of letters of the alphabet, we can use the function range . Example in PHP: $letras = range('a', 'z'); Result: Array ( [0] => a [1] => b [2] => c [3] => d [4...
asked by 13.08.2015 / 15:25
2
answers

How to access the elements of a set?

I'm studying about sets ( set ) in Python because I'm going to use an algorithm to find paths in a graph, it's for a college discipline I'm having. I created two assembly examples using two different notations. Look at the illustration...
asked by 06.09.2018 / 20:59
1
answer

Why does "int ('1111', 2)" return "15" in Python?

Why this output? Code: a = int('1111', 2) print(a) Output: 15     
asked by 21.11.2017 / 13:01
3
answers

Check if list value "1" contains list "2"

I have two lists: track_list = ['iphone 6', 'iphone 5', 'moto x2', 'galaxy s6'] tweets_data = ['Eu queria um iphone 6 sérião', 'nao gostei do moto x2', 'iphone 5 é coisa do passado'] I want to check if the...
asked by 19.10.2015 / 21:10
2
answers

How to add parallelism in execution with the subprocess module?

The code will be used on 2 virtual testing machines (Linux and Windows). The code below works, but every time I run a program, for example notepad , the prompt gets stuck until I quit the program. How do I run multiple programs at...
asked by 03.08.2016 / 17:41