Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [106]: import faker
- In [107]: f = faker.Faker()
- In [108]: f.address
- Out[108]: <bound method Provider.address of <faker.providers.address.en_US.Provider object at 0x7fb13c8f9cf8>>
- In [109]: f.address()
- Out[109]: '85599 Adam Coves\nJamesville, AS 30441'
- In [110]: f.address()
- Out[110]: '5034 Harrington Fall Apt. 741\nTinaborough, CA 04084'
- In [111]: f.address()
- Out[111]: '7701 Mark Glens Apt. 687\nNew Kristafort, DE 51109'
- In [112]: f.address()
- Out[112]: 'USCGC Carroll\nFPO AA 19647'
- In [113]: f.address()
- Out[113]: '55810 Barbara Field Apt. 090\nLake Anthony, IA 50583'
- In [114]: f.ascii_email
- Out[114]: <bound method Provider.ascii_email of <faker.providers.internet.en_US.Provider object at 0x7fb13c916898>>
- In [115]: f.ascii_email()
- Out[115]: 'anna01@ruiz-moore.com'
- In [116]: f.ascii_email()
- Out[116]: 'rmadden@hotmail.com'
- In [117]: f.ascii_email()
- Out[117]: 'sanchezfelicia@gmail.com'
- In [118]: f.bank_country()
- Out[118]: 'GB'
- In [119]: f.century
- Out[119]: <bound method Provider.century of <faker.providers.date_time.en_US.Provider object at 0x7fb13c906a20>>
- In [120]: f.century()
- Out[120]: 'III'
- In [121]: f.century()
- Out[121]: 'XVI'
- In [122]: f.century()
- Out[122]: 'XVIII'
- In [123]: f.city
- Out[123]: <bound method Provider.city of <faker.providers.address.en_US.Provider object at 0x7fb13c8f9cf8>>
- In [124]: f.city()
- Out[124]: 'Port Danielle'
- In [125]: f.city()
- Out[125]: 'Gallowayshire'
- In [126]: f.city()
- Out[126]: 'Port Colton'
- In [127]: f.city()
- Out[127]: 'East Vanessamouth'
- In [128]: f.city()
- Out[128]: 'West Crystal'
- In [129]: f.city()
- Out[129]: 'Lake Ravenburgh'
- In [130]: f.first_name()
- Out[130]: 'Shannon'
- In [131]: f.first_name()
- Out[131]: 'Ronald'
- In [132]: f.first_name()
- Out[132]: 'Cassandra'
- In [133]: f.first_name()
- Out[133]: 'Jonathan'
- In [134]: f.last_name()
- Out[134]: 'Waters'
- In [135]: f.last_name()
- Out[135]: 'Villegas'
- In [136]: f.last_name()
- Out[136]: 'Johnson'
- In [137]: f.last_name()
- Out[137]: 'Chen'
- In [138]: f.last_name()
- Out[138]: 'Wright'
- In [139]:
- In [139]: f.day_of_week()
- Out[139]: 'Wednesday'
- In [140]: f.day_of_week()
- Out[140]: 'Sunday'
- In [141]: f.day_of_week()
- Out[141]: 'Friday'
- In [142]: f.day_of_week()
- Out[142]: 'Friday'
- In [143]: f.paragraph()
- Out[143]: 'Feel control suddenly wind. Shoulder way common we hour.'
- In [144]: f.paragraph()
- Out[144]: 'Bed head thing test discussion thousand admit. State long hear agreement.'
- In [145]: f.paragraph()
- Out[145]: 'Risk huge program memory. Radio light fact prevent. Voice past decision.'
- In [146]: mytext = f.paragraph?
- Signature: f.paragraph(nb_sentences=3, variable_nb_sentences=True, ext_word_list=None)
- Docstring:
- :returns: A single paragraph. For example: 'Sapiente sunt omnis. Ut
- pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.'
- Keyword arguments:
- :param nb_sentences: around how many sentences the paragraph should contain
- :param variable_nb_sentences: set to false if you want exactly ``nb``
- sentences returned, otherwise the result may include a number of
- sentences of ``nb`` +/-40% (with a minimum of 1)
- :param ext_word_list: a list of words you would like to have instead of
- 'Lorem ipsum'.
- :rtype: str
- File: ~/.local/lib/python3.6/site-packages/faker/providers/lorem/__init__.py
- Type: method
- In [147]: mytext = f.paragraph(10)
- In [148]: mytext
- Out[148]: 'Middle amount too political else prepare possible. Mrs such recognize party church fine probably. Use carry hospital real act different. A girl drug establish. Worry sort other modern language positive. Itself significant onto alone. Her capital that coach writer drive rock.'
- In [149]: mytext.count('M')
- Out[149]: 2
- In [150]: mytext.count('a')
- Out[150]: 18
- In [151]: len(mytext)
- Out[151]: 275
- In [152]: mytext.count('.')
- Out[152]: 7
- In [153]: mytext.count('?')
- Out[153]: 0
- In [154]: mytext.count('!')
- Out[154]: 0
- In [155]: class Tv:
- ...: def __init__(self):
- ...: self.model = ''
- ...: self.size = ''
- ...: self.color = ''
- ...: self.is_smart = False
- ...:
- In [156]:
- In [156]: meetingroomtv = Tv()
- In [157]: meetingroomtv.model = 'LG'
- In [158]: meetingroomtv.color = 'Black'
- In [159]: meetingroomtv.size = '50inch'
- In [160]:
- In [160]:
- In [160]: meetingroomtv.model
- Out[160]: 'LG'
- In [161]: meetingroomtv.color
- Out[161]: 'Black'
- In [162]: meetingroomtv.size = '50inch'
- In [163]: class Tv:
- ...: def __init__(self):
- ...: self.model = ''
- ...: self.size = ''
- ...: self.color = ''
- ...: self.is_smart = False
- ...: def power_on(self):
- ...: print("starting tv...")
- ...:
- In [164]: meetingroomtv = Tv()
- In [165]: meetingroomtv.size = '50inch'
- In [166]: meetingroomtv.color = 'Black'
- In [167]: meetingroomtv.power_on()
- starting tv...
- In [168]:
- In [168]: class Tv:
- ...: def __init__(self, usermodel, usersize, usercolor, useris_smart):
- ...: self.model = usermodel
- ...: self.size = usersize
- ...: self.color = usercolor
- ...: self.is_smart = useris_smart
- ...: def power_on(self):
- ...: print("starting tv...")
- ...:
- ...:
- In [169]: meetingroomtv = Tv('LG', '50', 'black', False)
- In [170]: meetingroomtv.power_on()
- starting tv...
- In [171]: class Tv:
- ...: def __init__(self, usermodel, usersize, usercolor, useris_smart=False)
- ...: :
- ...: self.model = usermodel
- ...: self.size = usersize
- ...: self.color = usercolor
- ...: self.is_smart = useris_smart
- ...: def power_on(self):
- ...: print("starting tv...")
- ...:
- ...:
- In [172]:
- In [172]: meetingroomtv = Tv('LG', '50', 'black')
- In [173]: meetingroomtv.is_smart
- Out[173]: False
- In [174]: meetingroomtv = Tv('LG', '50', 'black', True)
- In [175]: meetingroomtv.is_smart
- Out[175]: True
- In [176]: meetingroomtv.model
- Out[176]: 'LG'
- In [177]: class Tv:
- ...: def __init__(self, usermodel, usersize, usercolor, useris_smart=False)
- ...: :
- ...: self.model = usermodel
- ...: self.size = usersize
- ...: self.color = usercolor
- ...: self.is_smart = useris_smart
- ...: def power_on(self):
- ...: print("starting tv...")
- ...:
- ...: def about(self):
- ...: print('model: ', self.model)
- ...: print('size: ', self.size)
- ...: print('color: ', self.color)
- ...: print('is smart: ?', self.is_smart)
- ...:
- In [178]: meetingroomtv = Tv('LG', '50', 'black', True)
- In [179]: meetingroomtv.power_on()
- starting tv...
- In [180]: class Tv:
- ...: def __init__(self, usermodel, usersize, usercolor, useris_smart=False)
- ...: :
- ...: self.model = usermodel
- ...: self.size = usersize
- ...: self.color = usercolor
- ...: self.is_smart = useris_smart
- ...: def power_on(self):
- ...: print("starting ", self.model, " tv ...")
- ...:
- ...: def about(self):
- ...: print('model: ', self.model)
- ...: print('size: ', self.size)
- ...: print('color: ', self.color)
- ...: print('is smart: ?', self.is_smart)
- ...:
- In [181]:
- In [181]: meetingroomtv = Tv('LG', '50', 'black', True)
- In [182]: meetingroomtv.power_on()
- starting LG tv ...
- In [183]: meetingroomtv.about()
- model: LG
- size: 50
- color: black
- is smart: ? True
- In [184]: class Human:
- ...: def __init__(self, name, age):
- ...: self.name = name
- ...: self.age = age
- ...: def sleep(self):
- ...: print(self.name, " is sleeping now..")
- ...: def eat(self):
- ...: print(self.name, " is eating now..")
- ...: def watch_tv(self, tv):
- ...: tv.power_on()
- ...: tv.about()
- ...: print(self.name, ' is watching tv now...')
- ...:
- In [185]: h = Human('ahmed', 500)
- In [186]: h.sleep()
- ahmed is sleeping now..
- In [187]: h.eat()
- ahmed is eating now..
- In [188]: h.sleep()
- ahmed is sleeping now..
- In [189]: h.watch_tv(meetingroomtv)
- starting LG tv ...
- model: LG
- size: 50
- color: black
- is smart: ? True
- ahmed is watching tv now...
- In [190]: import faker
- In [191]: class MyFaker:
- ...: def __init__(self):
- ...: pass
- ...: def email(self):
- ...: return "abc@gmail.com"
- ...:
- In [192]: myf = MyFaker()
- In [193]: myf.email()
- Out[193]: 'abc@gmail.com'
- In [194]: myf.email()
- Out[194]: 'abc@gmail.com'
- In [195]: myf.email()
- Out[195]: 'abc@gmail.com'
- In [196]: myf.email()
- Out[196]: 'abc@gmail.com'
- In [197]: myf.email()
- Out[197]: 'abc@gmail.com'
- In [198]: import random
- In [199]: class MyFaker:
- ...: def __init__(self):
- ...: pass
- ...: def email(self):
- ...: emails = ['abc.@gmail.com', 'xyz@yahoo.com']
- ...: return random.choice(emails)
- ...:
- ...:
- In [200]: myf = MyFaker()
- In [201]: myf.email()
- Out[201]: 'abc.@gmail.com'
- In [202]: myf.email()
- Out[202]: 'abc.@gmail.com'
- In [203]: myf.email()
- Out[203]: 'abc.@gmail.com'
- In [204]: myf.email()
- Out[204]: 'abc.@gmail.com'
- In [205]: myf.email()
- Out[205]: 'xyz@yahoo.com'
- In [206]: myf.email()
- Out[206]: 'abc.@gmail.com'
- In [207]: myf.email()
- Out[207]: 'xyz@yahoo.com'
- In [208]: class MyFaker:
- ...: def __init__(self):
- ...: pass
- ...: def email(self):
- ...: emails = ['abc.@gmail.com', 'xyz@yahoo.com']
- ...: return random.choice(emails)
- ...:
- ...: def some_number(self):
- ...: return random.choice(range(0,100))
- ...:
- In [209]: myf = MyFaker()
- In [210]: myf.some_number()
- Out[210]: 90
- In [211]: myf.some_number()
- Out[211]: 80
- In [212]: myf.some_number()
- Out[212]: 30
- In [213]: myf.some_number()
- Out[213]: 40
- In [214]: myf.some_number()
- Out[214]: 99
- In [215]: myf.some_number()
- Out[215]: 73
- In [216]:
- In [216]: myf.some_number()
- Out[216]: 36
- In [217]: class Todo:
- ...: def __init__(self):
- ...: self.tasks = []
- ...: def add(self):
- ...: newtask = input('new task? ')
- ...: self.tasks.append(newtask)
- ...:
- In [218]: class Todo:
- ...: def __init__(self, userowner):
- ...: self.tasks = []
- ...: self.owner = userowner
- ...: def add(self):
- ...: newtask = input('new task? ')
- ...: self.tasks.append(newtask)
- ...:
- In [219]:
- In [219]: t = Todo('ahmed')
- In [220]: t.add()
- new task? sleep
- In [221]: t.add()
- new task? eat
- In [222]: t.tasks
- Out[222]: ['sleep', 'eat']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement