Questions tagged as 'python'

1
answer

"If (a == b):" or "if a == b:" in Python, which one is correct?

I have already seen two ways to express conditional in python, using or not (). With (): if(a): print('x') Without (): if a: print('x') Which of the two ways would be the most correct to use?     
asked by 04.03.2018 / 23:14
1
answer

How to open a csv created in Python without opening an import screen?

I have already created a csv in Python in several ways as can be seen below, but every time I open the file opens the import screen as below. Why does this happen? And how can I make the file open directly within the csv defaults? Detai...
asked by 24.01.2018 / 16:40
3
answers

How to print without line break in Python

matriz = [] def create_matriz(a, b): for contador in range(a): matriz.append( [0] * b ) def print_matriz(txt): cont = 0 for j in range(a): for i in range(b): if txt[cont] == "0": matriz[i][...
asked by 06.06.2017 / 06:15
1
answer

Python / Django time interval

I need to create a time grid for a calendar: I have the following information in the Django template: Starting time: 08:00 End time: 6:00 p.m. Interval in minutes 00:30 I would like to implement something like: for hora in range...
asked by 06.05.2017 / 18:45
1
answer

How to merge an array?

I'm writing a program that merges the values of two arrays, with the same amount of values. The program receives as input the amount of values in each array. It then receives the values and, finally, prints the merged values, as follows: Entr...
asked by 10.04.2016 / 14:24
4
answers

How to add entries in a dictionary?

How do I add entries provided by a user in a dictionary? For example: Entry: 1 abcde 2 adecd 3 aaabb The created dictionary would be: dicionario = {'abcde' : 1, 'adecd' : 2, 'aaabb' : 3} or dicionario = {1 : 'abcde', 2 : 'adecd',...
asked by 17.04.2016 / 14:33
1
answer

404 Django Python Error

This is the error I'm having: AsyoucanseeinthelistofURLs,thenumber8isequaltothe"current url" given below. My url list: from django.conf.urls import include, url from django.contrib import admin from principal.views import IndexView, Log...
asked by 09.11.2016 / 16:54
1
answer

Disadvantages for Brazilians using Google App Engine

I've done some app and some tests with Google App Engine. I've read about several of their limitations, and some of them are a bit boring, but nothing that worries me much, because as I intend to do something new, you already build thinking a...
asked by 22.06.2016 / 03:42
2
answers

Refactoring random datetime generation (Python)

I accept suggestions to improve this code link import random import datetime def gen_timestamp(min_year=1915, max_year=1996): # gera um datetime no formato yyyy-mm-dd hh:mm:ss.000000 year = random.randint(min_year, max_year)...
asked by 25.10.2015 / 02:51
1
answer

Python doubts syntax

Galera was studying python and saw on a website this line: self.brotcl.plugins.runCustumcomand() I know that self is referencing a class but and these three variables together like that?     
asked by 25.10.2015 / 01:38