operator in Python

0 votes
In the following Code:

class Point(object):
    """blub"""
    #class variables and methods

blank = Point
blank.x = 2.0
blank.y = 6.0    
print('(%g,%g)' % (blank.x,blank.y))

It prints (2.0, 6.0), i.e. the values in blank.x and blank.y.

I don't understand the % operator in front of the (blank.x, blank.y) in the last line. What does it do and where can I find it in the documentation?
Nov 12, 2018 in Python by Sayantini
• 140 points
923 views

1 answer to this question.

0 votes
When you use '(%g,%g)', it is the template and (blank.x,blank.y) are the values which need to be filled in place of  %g and %g and % operator is used to perform the same. It is called interpolation or formatting operator.
answered Nov 12, 2018 by ana1504.k
• 7,910 points

Related Questions In Python

0 votes
0 answers

Python: % operator in print() statement

I just came across this Python code, ...READ MORE

Apr 18, 2022 in Python by Edureka
• 13,620 points
595 views
0 votes
1 answer

What are the ternary conditional operator in Python?

The Ternary Conditional operator was added in ...READ MORE

answered Sep 19, 2018 in Python by SDeb
• 13,300 points
725 views
0 votes
1 answer

How does % work in Python?

The % (modulo) operator yields the remainder ...READ MORE

answered Oct 10, 2018 in Python by SDeb
• 13,300 points
834 views
0 votes
1 answer

% operator in print() statement

'(%g,%g)' is the template and (blank.x,blank.y) are the values which ...READ MORE

answered Nov 15, 2018 in Python by findingbugs
• 3,260 points
2,190 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
1 answer

Power Math in Python

When you use "^" operator, it is ...READ MORE

answered Nov 12, 2018 in Python by ana1504.k
• 7,910 points
747 views
+1 vote
1 answer

ssh first with mysqldb in python

Setup an ssh tunnel before you use ...READ MORE

answered May 23, 2019 in Python by ana1504.k
• 7,910 points
2,786 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP