Wednesday, 18 September 2019

The Joy of Computing using Python: Programming Assignments 1,2 & 3

Programming Assignment - 1: Duplicate Elements

With a given list L of integers, write a program to print this list L after removing all duplicate values with original order preserved.

Example:

If the input list is

12 24 35 24 88 120 155 88 120 155

Then the output should be

12 24 35 88 120 155

Explanation:
Third, seventh and ninth element of the list L has been removed because it was already present.

Input Format:
In one line take the elements of the list L with each element separated by a space.

Output Format:
Print the elements of the modified list in one line with each element separated by a space.

Example:
Input:
12 24 35 24

Output:
12 24 35

Program Code:

o=list(map(int,input().split()))
d=[]
for i in o:
  if i not in d:
    d.append(i)
print(*d,end="")


Programming Assignment-2: Panagrams


A panagram is a sentence containing every 26 letters in the English alphabet. Given a string S, check if it is panagram or not.

Input Format:
The first line contains the sentence S.

Output Format:
Print 'YES' or 'NO' accordingly

Example:

Input:
The quick brown fox jumps over the lazy dog

Output:
YES

Program Code: 

alphabet=[]
for i in range(97,123):
    alphabet.append(chr(i))
s=input()
s=s.lower()
d=set(s)
d=list(d)
for i in d:
    if i in alphabet:
        alphabet.remove(i)
if len(alphabet)==0:
  print("YES",end="")
else:
  print("NO",end="")


Programming Assignment-3: Vowels


Given a string S of lowercase letters, remove consecutive vowels from S. After removing, the order of the list should be maintained.

Input Format:

Sentence S in a single line

Output Format:
Print S after removing consecutive vowels

Example:

Input:
your article is in queue

Output:
yor article is in qu

Explanation:

In the first word, 'o' and 'u' are appearing together, hence the second letter 'u' is removed. In the fifth word, 'u', 'e', 'u' and 'e' are appearing together, hence 'e', 'u', 'e' are removed.

Program Code:
def vow(l): 
  
    return ((l == 'a') or (l == 'e') or (l == 'i') or (l == 'o') or (l == 'u')) 
def final(ip): 
    print(ip[0], end = ""); 
    for i in range(1,len(ip)):
        if ((vow(ip[i - 1]) != True) or 
            (vow(ip[i])!= True)):          
            print(ip[i], end = "")
ip=input() 
final(ip)

7 comments:

  1. Sir, could you please post digital circuits week 8 assignment answers as soon as possible...Only few hours left...We want to verify

    ReplyDelete
  2. Sir, could you please post joy of computing week 9 assignment answers as soon as possible...

    ReplyDelete
  3. Sir can you post assignment 9 for joy of computing python

    ReplyDelete
  4. Really a awesome blog for the freshers. Thanks for posting the information.
    Python Training in Delhi

    ReplyDelete



  5. Digital Lync offers one of the best Online Courses Hyderabad with a comprehensive course curriculum with Continuous Integration, Delivery, and Testing. Elevate your practical knowledge with quizzes, assignments, Competitions, and Hackathons to give a boost to your confidence with our hands-on Full Stack Training. An advantage of the online Cources development course in Hyderabad from Digital Lync is to get industry-ready with Career Guidance and Interview preparation.
    DevOps Training Institute
    Python Training Institute
    AWS Training Institute
    Online Full Stack Developer Course Hyderabad
    Online Python Course Hyderabad
    Online AWS Training Course Hyderabad
    Online Devops Course Hyderabad
    Digital Marketing Training Hyderabad

    ReplyDelete