"If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with that file as input instead. This is known as creating a script. As your program gets longer, you may want to split it into several files for easier maintenance. You may also want to use a handy function that you’ve written in several programs without copying its definition into each program.
To support this, Python has a way to put definitions in a file and use them in a script or in an interactive instance of the interpreter. Such a file is called a module; definitions from a module can be imported into other modules or into the main module (the collection of variables that you have access to in a script executed at the top level and in calculator mode).
A module is a file containing Python definitions and statements. The file name is the module name with the suffix
.py
appended. Within a module, the module’s name (as a string) is available as the value of the global variable __name__
."__future__ _weakrefset hashlib sched
_ast _winapi heapq secrets
_asyncio abc hmac select
_bisect aifc html selectors
_blake2 antigravity http setuptools
_bootlocale argparse idlelib shelve
_bz2 array idna shlex
_codecs ast imaplib shutil
_codecs_cn asynchat imghdr signal
_codecs_hk asyncio imp site
_codecs_iso2022 asyncore importlib smtpd
_codecs_jp atexit inspect smtplib
_codecs_kr audioop io sndhdr
_codecs_tw base64 ipaddress socket
_collections bdb itertools socketserver
_collections_abc binascii json sqlite3
_compat_pickle binhex keyword sre_compile
_compression bisect lib2to3 sre_constants
_csv bs4 linecache sre_parse
_ctypes builtins locale ssl
_ctypes_test bz2 logging stat
_datetime cProfile lzma statistics
_decimal calendar macpath string
_distutils_findvs certifi macurl2path stringprep
_dummy_thread cgi mailbox struct
_elementtree cgitb mailcap subprocess
_functools chardet marshal sunau
_hashlib chunk math symbol
_heapq cmath mimetypes symtable
_imp cmd mmap sys
_io code modulefinder sysconfig
_json codecs msilib tabnanny
_locale codeop msvcrt tarfile
_lsprof collections multiprocessing telnetlib
_lzma colorsys netrc tempfile
_markupbase compileall nntplib test
_md5 concurrent nt textwrap
_msi configparser ntpath this
_multibytecodec contextlib nturl2path threading
_multiprocessing copy numbers time
_opcode copyreg opcode timeit
_operator crypt operator tkinter
_osx_support csv optparse token
_overlapped ctypes os tokenize
_pickle curses parser trace
_pydecimal datetime pathlib traceback
_pyio dbm pdb tracemalloc
_random decimal pickle tty
_sha1 difflib pickletools turtle
_sha256 dis pip turtledemo
_sha3 distutils pipes types
_sha512 doctest pkg_resources typing
_signal dummy_threading pkgutil unicodedata
_sitebuiltins easy_install platform unittest
_socket email plistlib urllib
_sqlite3 encodings poplib urllib3
_sre ensurepip posixpath uu
_ssl enum pprint uuid
_stat errno profile venv
_string faulthandler pstats warnings
_strptime filecmp pty wave
_struct fileinput py_compile weakref
_symtable fnmatch pyclbr webbrowser
_testbuffer formatter pydoc winreg
_testcapi fractions pydoc_data winsound
_testconsole ftplib pyexpat wsgiref
_testimportmultiple functools queue xdrlib
_testmultiphase gc quopri xml
_thread genericpath random xmlrpc
_threading_local getopt re xxsubtype
_tkinter getpass reprlib zipapp
_tracemalloc gettext requests zipfile
_warnings glob rlcompleter zipimport
_weakref gzip runpy zlib
if you go to windows Powershell and type first Python it will show which version of python is installed
then type help()
In your PowerShell (Terminal) program, run python. You run things
in Terminal by just typing the name and pressing Enter. If you type
python and it does not run, then you have to reinstall Python and make
sure you check the box for “Add python to the PATH.” It’s very small so
look carefully.
8. Type quit(), and press Enter to exit python.
9. You should be back at a prompt similar to what you had before you typed
python. If not, find out why.
No comments:
Post a Comment