How to print values side by side? [duplicate] - python

This question already has answers here:
Print new output on same line [duplicate]
(7 answers)
Closed 5 years ago.
How can i print dictionary values side by side ?
Could you please assists me ?

Use print(hashstring, end = ' ')

Related

Workings for addition calculator is not showing [duplicate]

This question already has answers here:
How do I put a variable’s value inside a string (interpolate it into the string)?
(9 answers)
Closed 1 year ago.
print ("Naomi's Calculator!")
print("Addition")
value_1= 10
value_2= 15
working= (value_1 "+" value_2)
print(working)
result=(value_1+value_2)
print(result)
working variable is wrong, i want the result to be like 10+15
value_1 and value_2 are int, you need to convert them in string if you want to see that output for working variable.
working = (str(value_1)+"+" +str(value_2))

Random number as file name [duplicate]

This question already has answers here:
How to insert a variable value in a string in python
(3 answers)
Closed 1 year ago.
So, I want to put a random number as my filename in f=open
I generated the number with d=random.randint(1,10)
and I want to put that as my filename in f=open.
f=open("test.txt", "x")
How can I do that?
I don't think you tried very hard to solve this yourself.
d = random.randint(1,10)
f = open(f"test{d}.txt",'w')

How to add / between spaces in a date [duplicate]

This question already has answers here:
Replacing instances of a character in a string
(17 answers)
Closed 4 years ago.
How can I take a string that returns it in a list with " / " between them, like dates.
for example
Taking 5,11,2013 and the output be 5/11/2013
Use str.replace() ?
date = '11,12,2019'
print(date.replace(',', '-'))
>> 11-12-2019

Augmented Assignment variable value [duplicate]

This question already has answers here:
Python integer incrementing with ++ [duplicate]
(7 answers)
Closed 6 years ago.
Sorry for a question that might sound dumb, but in Python, is there a way to easily add 1 to a variable value, rather than doing
var_one = 1
var_one = var_one + 1
all the time?
Try this one on for size:
var_one += 1

Python 3 - convert mathematical action to integer [duplicate]

This question already has answers here:
Math operations from string [duplicate]
(8 answers)
Closed 6 years ago.
I have a string with a formula 5 - 3, and I need to get the result in integer. How could I do that?
use eval function:
eval("5 - 3") # 2
test = "5-3"
print(eval(test))
Gives 2

Categories

Resources