NPTEL Course a fun filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love with the most sought after skill of the 21st century. The course brings programming to your desk with anecdotes, analogies and illustrious examples. Turning abstractions to insights and engineering to art, the course focuses primarily to inspire the learner’s mind to think logically and arrive at a solution programmatically. As part of the course, you will be learning how to practice and culture the art of programming with Python as a language. At the end of the course, we introduce some of the current advances in computing to motivate the enthusiastic learner to pursue further directions. The Joy of Computing using python is a fun filled course offered by NPTEL.

**The Joy Of Computing Using Python Week 5 Assignment.**

**INTENDED AUDIENCE : **Any interested audience**PREREQUISITES :** 10th standard/high school**INDUSTRY SUPPORT : **Every software company is aware of the potential of a first course in computer science. Especially of a first course in computing, done right.

### Course Layout

- Motivation for Computing
- Welcome to Programming!!
- Variables and Expressions : Design your own calculator
- Loops and Conditionals : Hopscotch once again
- Lists, Tuples and Conditionals : Lets go on a trip
- Abstraction Everywhere : Apps in your phone
- Counting Candies : Crowd to the rescue
- Birthday Paradox : Find your twin
- Google Translate : Speak in any Language
- Currency Converter : Count your foreign trip expenses
- Monte Hall : 3 doors and a twist
- Sorting : Arrange the books
- Searching : Find in seconds
- Substitution Cipher : What’s the secret !!
- Sentiment Analysis : Analyse your Facebook data
- 20 questions game : I can read your mind
- Permutations : Jumbled Words
- Spot the similarities : Dobble game
- Count the words : Hundreds, Thousands or Millions.
- Rock, Paper and Scissor : Cheating not allowed !!
- Lie detector : No lies, only TRUTH
- Calculation of the Area : Don’t measure.
- Six degrees of separation : Meet your favourites
- Image Processing : Fun with images
- Tic tac toe : Let’s play
- Snakes and Ladders : Down the memory lane.
- Recursion : Tower of Hanoi
- Page Rank : How Google Works !!

**Programming Assignment 1**

**Question 1** : You are given a string S. Write a function count_letters which accepts the string S and returns a dictionary containing letters (including special character) in string S as keys and their count in string S as values.

(input and output is handled by us, you just need to write the function and return the dictionary)

Input

The Joy of computing

Output

{‘T’: 1, ‘h’: 1, ‘e’: 1, ‘ ‘: 3, ‘j’: 1, ‘o’: 3, ‘y’: 1, ‘f’: 1, ‘c’: 1, ‘m’: 1, ‘p’: 1, ‘u’: 1, ‘t’: 1, ‘i’: 1, ‘n’: 1, ‘g’: 1}

` ````
```def count_letters(S):
d={}
for i in S:
d[i]=0
for i in S:
d[i]+=1
return d
if __name__ == "__main__":
S = input()
d = count_letters(S)
#~~~THERE IS SOME INVISIBLE CODE HERE~~~

**Programming Assignment 2**

**Question 2** : You are given a list L. Write a function uniqueE which will return a list of unique elements is the list L in sorted order. (Unique element means it should appear in list L only once.)

Input is handled by us.

Input

[1,2,3,3,4,4,2,5,6,7]

Output

[1,5,6,7]

Explanation

Elements 1,5,6,7 appears in the input list only once.

` ````
```def uniqueE(L):
d = {}
for i in L:
d[i]=0
for i in L:
d[i]+=1
res = []
for key, value in d.items():
if value==1:
res.append(key)
res.sort()
return res
L = [int(i) for i in input().split()]
print(uniqueE(L))

**Programming Assignment 3**

**Question 3** : You are given a list L. Write a program to print first prime number encountered in the list L.(Treat numbers below and equal to 1 as non prime)

Input is handled by us.

Input

[1,2,3,4,5,6,7,8,9]

output

2

Explanation

Since 2 is the first prime number is list L, therefor it is printed.

` ````
```#~~~THERE IS SOME INVISIBLE CODE HERE~~~
def isprime(num):
if num<=1:
return False
if num==2:
return True
for i in range(3,num-1):
if num%i == 0:
return False
return True
for k in L:
if isprime(k):
print(k,end="")
break
else:
continue