<jupyter_start><jupyter_text>Range function* Immutable sequence of numbers<jupyter_code>help(range)<jupyter_output><empty_output><jupyter_text>* Range with only stop parameter<jupyter_code>list(range(10))<jupyter_output><empty_output><jupyter_text>* Range with start,stop and step parameters<jupyter_code>list(range(0,15,5))<jupyter_output><empty_output><jupyter_text>* Range with negative step<jupyter_code>list(range(10,-10,-2))<jupyter_output><empty_output><jupyter_text>Numerical Datatype * Print even numbers from 0 to 10<jupyter_code>i = 0
while(i <= 10):
    if i%2 == 0:
        print('{} is an even number'.format(i))
    i +=1
for i in range(11):
    if i%2 == 0:
        print('{} is an even number'.format(i))
else:
    print(i)<jupyter_output><empty_output><jupyter_text>Nested for loops to check for prime numbers<jupyter_code>for n in range(2, 10):
    for x in range(2, n):
        if n % x == 0:
            print(n, 'equals', x, '*', n//x)
            break
    else:        
        print(n, 'is a prime number')<jupyter_output><empty_output><jupyter_text>1. Write a program to take list of integers and print the integers occurring two or more times.<jupyter_code>lst_num = [1,2,3,4,5,5,6,3,7,8,8]
set_num = set(lst_num)
set_result = set()
for i in set_num:
    if lst_num.count(i) >=2:
        print(i)<jupyter_output><empty_output><jupyter_text>Strings<jupyter_code>name_1 = '<NAME>'
name_2 = '<NAME>'<jupyter_output><empty_output><jupyter_text>* Print the characters of the string<jupyter_code>index = 0 
while(index < len(name_1)):
    print(name_1[index],end=' ')
    index = index + 1
for char in name_1:
    print(char,end=' ')<jupyter_output><empty_output><jupyter_text>* Using nested loops to find the characters which are present in other string<jupyter_code>for char_1 in name_1:
    if char_1 in name_2:
        print(char_1,end=' ')<jupyter_output><empty_output><jupyter_text>Lists<jupyter_code>lst_num = list(range(10,20))
lst_num
for num in lst_num:
    print('Square of {} is {}'.format(num,num**2))<jupyter_output><empty_output><jupyter_text>2. For the list given below, Identify and print the datatype of the objects into numerical or string        lst_mxd = ['python',1,2,3,4.56,(12,5)]<jupyter_code>lst_mxd = ['python',1,2,3,4.56,(12,5)]
for item in lst_mxd:
    if (type(item)==int) or (type(item) == float) :
        print('{} is a numerical datatype'.format(item))
    elif (isinstance(item,str)):
        print('{} is a string datatype'.format(item))
    else:
        print('{} :datatype unknown'.format(item))<jupyter_output><empty_output><jupyter_text>Dictionary<jupyter_code>dict_cat_1 = {'fruits':'banana','colours':'orange','animals':'dog','tech':'C'}
dict_cat_1
print(dict_cat_1.items())
for item in dict_cat_1.items():
    print(item,type(item))
dict_cat_2 = {'fruits':['banana','apple'],
              'colours':['orange','red'],
              'animals':['dog','cat'],
              'tech':['C','python']}
for (key,value) in dict_cat_2.items():
    if key == 'fruits':
        value.append('grapes')
    elif key == 'colours':
        value.append('green')
    elif key == 'animals':
        value.append('Lion')
    elif key == 'tech':
        value.append('C++')

dict_cat_2   
dict_cat_3 = {'fruits':{'banana','apple'},
              'colours':{'orange','red'},
              'animals':{'dog','cat'},
              'tech':{'C','python'}}
for (key,value) in dict_cat_3.items():
    if key == 'fruits':
        value.add('strawberry')
    elif key == 'colours':
        value.add('green')
    elif key == 'animals':
        value.add('Lion')
    elif key == 'tech':
        value.add('C++')

dict_cat_3<jupyter_output><empty_output><jupyter_text>3. Write a program to count the number of time each word occurs in the sentence given below     str_words = 'She sells sea shells on the sea shore'<jupyter_code># %load loop_3.py
str_words = 'She sells sea shells on the sea shore   '
words_split = str_words.lower().split()
print(words_split)
dict_count = {}
for word in words_split:
    dict_count[word] = dict_count.get(word,0) +1
    print(dict_count)
print(dict_count)
dict_count_mod = {}
for word in words_split:
    if word not in dict_count_mod.keys():
        dict_count_mod[word] = 1
    else:
        dict_count_mod[word] = dict_count_mod[word] + 1
    print(dict_count_mod)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1535288725939505, 'fraction_numerical': 0.02153987167736022, 'mean_word_length': 4.2781136638452235, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 60, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '641449', 'license': 'MIT', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1581, 'n_words': 343, 'path': 'Day_7/.ipynb_checkpoints/Looping-checkpoint.ipynb', 'repo_name': 'chetanadhikary/weekday_python_inclass', 'size': '4376'}