Linked Questions

98 votes
4 answers
90k views

In Python there seem to be two different ways of generating formatted output: user = "Alex" number = 38746 print("%s asked %d questions on stackoverflow.com" % (user, number)) print("{0} asked {1} ...
Alex's user avatar
  • 45k
3 votes
2 answers
3k views

What does a % sign mean in python when it is not a modulo or a string formatter? I came across it in this baffling block of code in the timeit module: # Don't change the indentation of the template; ...
Matthew Adams's user avatar
2 votes
3 answers
9k views

I'm new to python, and I just want to know the difference between those examples. Does it differ when it comes to the execution speed? When do I use one of them instead of the other? x: int = 64 print(...
Mohamed A. Abdallah's user avatar
1 vote
3 answers
15k views

I need to write the line numbers to an already existing text file in python 3. They have asked for the first 5 columns of the text file to contain a 4 digit line number followed by a space. I've ...
Emj's user avatar
  • 23
2 votes
2 answers
830 views

I use python 3.4 and I can format strings in two ways: print("%d %d" %(1, 2)) and print("{:d} {:d}".format(1, 2)) In documentation they show examples only using 'format'. Do it mean that using '%' ...
user3654650's user avatar
  • 6,333
-1 votes
1 answer
7k views

I have been asked to use the % placeholder to write something in python. I don't know how to do it can you help.
Nico's user avatar
  • 13
2 votes
1 answer
6k views

I have the following code def latex_template(name, title): return '\n'.join((r"\begin{figure}[ht]", r" This is a custom LaTeX template!", r&...
IloveMath's user avatar
  • 241
2 votes
1 answer
3k views

How do i convert an f-string in python so that it can be printed by python version older than 3.6? print(f"Player 1: {move1} Player 2: {move2}") When I try to run this in Python (3.5.3) it gives me ...
Amanda's user avatar
  • 31
0 votes
2 answers
4k views

New to Python, I have the following script: #!/usr/bin/env python3 import sys env = sys.argv[1:] # The name of the environment we're executing over ('Dev', 'Test', 'Prod', etc) print('Executing ...
hotmeatballsoup's user avatar
-1 votes
3 answers
3k views

I have to write a program that reads in a whole number and prints out that number divided by two. This is my code: a= int(input("Number: ")) h= a/2 print("Half number: " + h) But I keep getting ...
poptrt00's user avatar
-1 votes
1 answer
1k views

I'm learning multithreading in python and I was reading through this answer. I understand most of the code however there is this one line which I simply don't understand and I don't know how to search ...
aaaakshat's user avatar
  • 873
0 votes
1 answer
1k views

I try to check file existence on a remote server. Everything works fine for me, except that I want to pass the file path as a variable. Here is what I do _,stdout,_=ssh.exec_command("[ -f d:/tryssh/...
AhmedWas's user avatar
  • 1,297
-1 votes
2 answers
665 views

I want the results to be in the format Date, Question, Name and Score file = open("results.csv", "a") file.write('Date, Question, Name, Score\n' + date + ',' question + ',' + name + ',' + score + '\...
JD245's user avatar
  • 61
-1 votes
1 answer
680 views

Hi i am reading a source and it has a line: fn = 'total-listmix-{}-{}.xml'.format(opt.os, opt.compiler) exept Exception as e: raise Exception('error merging coverage: {}'.format(e)) I think the {}...
Thanh Nguyen's user avatar
-3 votes
1 answer
334 views

I'm doing some coursework and I need to determine a character's name. This is what I have so far: charOne=input("Please input your first character's name: ") charTwo=input("Please input your second ...
Michael Wade's user avatar

15 30 50 per page
1
2 3 4 5
13