<jupyter_start><jupyter_text>Python Tutorial __________________________________ Python is an easy to learn, powerfull programming language. it has efficient high-level data structures and simple but effective approach to object-oriented programming. Python's elegant syntax and dynamci typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms. The Python interpreter and the extensive standard library are freely available in source on binary form for all major platforms from the [Python web site](https://www.python.org/)   Introduction to PythonIn the following example, input and output are distinguished(भेद देखाउनु) by the presence or absence of prompts([>>>](https://docs.python.org/3/glossary.htmlterm-0) ...): to repeat the examples: lines that do not begin with a prompt are output from the interpreter. Note that a secondary prompt on a line by itself in an example means you must type a blank line; this is used to end a multi-line command. Many of the examples in this manual, even those entered at the interactive prompt, include comments. Comments in Pythn start with the hash character `` and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal. A hash character within a string literal is just a hash character. Since comments are clarify code and are not interpreted by Python, they may be omitted when typing in examples.   Using Python as a Calculator Let's try some simple Python commands. start the interpreter and wait fo rthe primary prompt, `>>>` (it shouldn't take long.)  Numbers The interpreter acts as a simple calculator: you can type an expression at it and it will write the value. Expression syntax is straightforward(सिधा): the operator `+`,`-`, `*` and `/` work just like in most other languages ( for example, Pascal or C); parentheses (`()`) can be used for grouping. For example:<jupyter_code>2+2<jupyter_output><empty_output><jupyter_text>![%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.JPG](attachment:%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.JPG)<jupyter_code>width = 20
height = 5 * 9
width * height<jupyter_output><empty_output><jupyter_text>ListsPython knows a number of compound data types, used to group together other values. The most versatile is the list. Which can be written as a list of comma-separated values (item) between square brackets. Lists might conatin items of different types, but usually the items all have the same type<jupyter_code>squares = [1,4,9,16,25]
squares<jupyter_output><empty_output><jupyter_text>Like strings (and all other built-in sequence types), lists can be indexed and sliced:<jupyter_code>4 ** 3
cubes = [1,8,27,65,125]
cubes.append(216)
cubes
cubes.append(7*3)
cubes
a, b = 0, 1
a
b
while a < 10:
    print(a)
    a, b = b, a+b
  
while a<1000:
    print(a, end = ',')
    a, b = b, a+b
# Strategy : Iterate over a copy
users = {'prakas': 'active',
         'pratima': 'active',
        'rajesh': 'inactive'}
print(users)

for user, status in users.copy().items():
    if status == 'inactive':
        del users[user]
# Strategy : create a new collection
active_users = {}

for user, status in users.items():
    if status == 'active':
        active_users[user] = status
active_users
print(users)
users.copy()
user, status in users.copy().items()
users.copy()
users
users.items()
user
status
users.copy().items()
name, status in users.copy().items()
name
status
name = ['prakas', 'pratima']
address = ['pyuthan', 'kathmandu']
name
address
result = {}
for fname, faddress in zip(name, address):
    result[fname] = faddress

print(result)    
    
    
name, address in result.items()
name
address
list(my_list)
fname, faddress in zip(name, address)
fname
faddress<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09623323013415892, 'fraction_numerical': 0.02089783281733746, 'mean_word_length': 4.803892215568863, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '239110', 'license': 'MIT', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1135, 'n_words': 488, 'path': 'Python_practis.ipynb', 'repo_name': 'prakasshrestha/PythonToPandas', 'size': '3876'}