Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,941 questions

51,879 answers

573 users

How to create a data set of points in Python

1 Answer

0 votes
from itertools import *     
import pprint

class CPoint:         
    def __init__(self, x, y):             
        self.x = x             
        self.y = y
        
    def __repr__(self):             
        return '({}, {})'.format(self.x, self.y)         

    def __gt__(self, other):             
        return (self.x, self.y) > (other.x, other.y)
        

# 4 = 0, 1, 2, 3
lst = list(map(CPoint, cycle(islice(count(), 4)), islice(count(), 10)))   

pprint.pprint(lst, width=2)  



'''
run:

[(0, 0),
 (1, 1),
 (2, 2),
 (3, 3),
 (0, 4),
 (1, 5),
 (2, 6),
 (3, 7),
 (0, 8),
 (1, 9)]
 
'''

 



answered May 24, 2019 by avibootz
edited May 24, 2019 by avibootz
...