# import turtle
#
#
# turtle.forward(400)
# turtle.circle(250)
# turtle.right(300)
#
# #the done function is used to hold the screen to see the result
# #or else we can use the time module and sleep function
#
#
# for i in range(0,100,10):
# turtle.forward(i)
# turtle.circle(i)
# turtle.right(i)
#
#
# turtle.done()
#if we need only the particular functions we can code like below
# from turtle import circle,done
#
# circle(70)
# done()
#or else we can do use *
# from turtle import *
#
# circle(70)
# done()
#we will get the error if we run the below piece of code
#since the done is common here,we declared as string,but the turtle method
#also has the "done" as function
done = "done with the drawing"
import turtle
turtle.forward(400)
turtle.circle(250)
turtle.right(300)
done()
print(done)
#here we can check the list of objects inside the
#inbuilt modules of the python
#we can also ctrl + click the module name to find the list of objects
print(dir())
#the above line will print
#['__annotations__', '__builtins__', '__cached__', '__doc__',
## '__file__', '__loader__', '__name__', '__package__', '__spec__']
print("="*40)
for i in dir():
print(i)
print(dir('__builtins__'))
#the above line will print
#['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__',
# '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__',
# '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__',
# '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
# '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
# 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find',
# 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier',
# 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust',
# 'lower',
# 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition',
# 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title',
# 'translate', 'upper', 'zfill']
print("="*40)
for i in dir('__builtins__'):
print(i)
#lets check for the shelve now
import shelve
print(dir())
# ['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__',
#'__name__',
# '__package__', '__spec__', 'i', 'shelve']
print(dir(shelve))
# ['BsdDbShelf', 'BytesIO', 'DbfilenameShelf', 'Pickler',
# 'Shelf', 'Unpickler', '_ClosedDict', '__all__', '__builtins__',
# '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__',
# 'collections', 'open']
print(dir(shelve.Shelf))
print('=='*20)
for i in dir(shelve.Shelf):
print(i)
#we can use the help function to know the functionality
help(shelve)
print("*"*20)
help(shelve.Shelf)
import random
help(random)
print("*"*20)
help(random.randint)
Sunday, 25 February 2018
Python Modules - Day 14(day later)
Subscribe to:
Posts (Atom)