<jupyter_start><jupyter_text>1. Python Syntax<jupyter_code>print("Hi\
      there")
print("""hi
there""")
# can’t use backslashes inside a docstring for statements dat aren’t a string
"""hi\
there"""
# Docstring in python
def func():
    """
    this function prints Hi
    """
    print("hi")
func()
# multistatement in one line
a=10;print(a)
print("we need a chaperon")
print("we need a 'chaperon'")
#python string formatter

# % operator 
print("the values of a = %s" % (a))
# Format Method
print("value of a is = {0}".format(a))
print("the value of a = {a}".format(a=10))<jupyter_output>the values of a = 10
value of a is = 10
the value of a = 10<jupyter_text>2. variables and data types<jupyter_code># multiple assignmets
age,name = 21,'app'
print(age,name)
# Deleting variables
del age
# python Numbers
a=1
b=1.0
c = 2+3j

print(type(a),type(b),type(c))
# tuples are immutable
subjects =('eng','maths')
subjects[0]
#subjects[0]= 'bio'
#Dictionaries
person={'city':'Goa','age':7}
type(person)
person['city'] 
#list of keys
person.keys()
# boolean
a = 2>1
type(a)
# sets
a = {1,2,3,4}
a
# set is unordered so doesn't suppport indexing
a.remove(4)
a.add(5)
a.add(5)
a
# Type Conversion
print(int(3.7),
int(True),
float(1),
float(2.011e-2),
str(2.1),
bool(0.1),
set([1,2,3]),
list("123"),
list({1,2,2,3}),
tuple({1,2,2,3}),
tuple(list(set([1,2]))))
# Global Variables
# When you declare a variable outside any context/scope, it is visible in teh whole program.
x = 1
def func1():
    y =3
    global x
    
    def funce2():
        nonlocal y 
    print(f"x:{x},y:{y}")
   

func1()

#print("func:{0} value:{1}".format(func1(),x))<jupyter_output>x:1,y:3<jupyter_text>3. Python Namespace and Variable Scope<jupyter_code>rank=1
id(rank)
id(1)
# there are three types of namesapace- global, local, and built-in.
# Current function’s variable scope- has local names
# Module’s variable scope- has global names
# The outermost variable scope- has built-in names<jupyter_output><empty_output><jupyter_text>4. Python Operator — Types of Operators in Python<jupyter_code># Exponentiation(**)
2**5
# Divides and returns the integer value of the quotient. It dumps the digits after the decimal.
4//3
# Modulus(%)
#Divides and returns teh value of teh remainder.

24 % 4
# Python Relational Operator
# Notequal to
1!=1.0
a=1
a+=2
a
a-=2
a
a/=2
a
a*=3
a
a**=2
a
a//=2
a
#Python Logical Operator
#AND
if(1<2) and (6>4):
    print("yes")
#OR
x=1>2 or 4>3
x
#NOT
a=not(0)
print(a)
# Membership Python Operator
# in
lst = ['a','b']
z='a' in lst
print(z)
z= 'a' not in lst
print(z)
# Python Identity Operator
'2' is '2'
2 is not '2'
# Python Bitwise Operator
# AND
2&3
3&4
# OR
2|3
# XOR
3 ^ 4
# Binary One’s Complement(~)
~3
# Binary Left-Shift(<<)
2<<2
# Binary Right-Shift(>>)
8>>2<jupyter_output><empty_output><jupyter_text>5. Python Data Structures – Lists, Tuples, Sets, Dictionaries<jupyter_code># LIST
languages=['C++','Python','Scratch',1,('app',23),False
          ] # You can put any kind of value in a list.
languages
# accessing list
languages[1]
languages[-2]
# Slicing a list
languages[1:4] # 1st to 3rd element
languages[:-2]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1631295533734558, 'fraction_numerical': 0.04054482103262591, 'mean_word_length': 4.762773722627737, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '117931', 'license': 'MIT', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1264, 'n_words': 372, 'path': 'python_tutorial/W1/23-12-19.ipynb', 'repo_name': 'procode7/python_tutorial', 'size': '3157'}