Saturday 12 August 2017

INLAB 3


******************************************************************************************
Q.)
‘pneumonoultramicroscopicsilicovolcanoconiosis’ is the longest word in a dictionary with 45 letters. Given the value of ‘i' and  the value of ‘k'   write an algorithm and the subsequent Python code to output the  five letters of the above longest string which are in the positions  that are the first five multiples of 2*i+k. If a multiple  is  greater than the length of the string,  then  continue the  counting from the beginning of the string. For example, if the value of i = 5 and k = 2 then the output letters are ‘r’, ‘c’, ‘n’, ‘e’, and ‘i'. The longest string is stored in a variable named as 's' in the precode, to be  used  for coding.
Input:
Read the value of 'i'
Read the velue of 'k'


Output:
Print the letters in the position that are the first five multiples of '2*i + k' , one letter in one line

Code:

s="pneumonoultramicroscopicsilicovolcanoconiosis"
i=int(input())
k=int(input())
p=2*i+k
i=1
while(i<6):
if(p*i-1>45):
s=s+s
print(s[p*i-1])
i=i+1


Procedure:
while(i<6):
if(p*i-1>45):
s=s+s
print(s[p*i-1])
i=i+1


Pseudo-Code:
1) let s = "pneumonoultramicroscopicsilicovolcanoconiosis"     - the longest word
2) Read 'i' as an integer input
3) Read 'k' as an integer input
4) let p = 2*i + k
5) let i=1
6) while 'i' is less then 6, repeat step 7
7) if p*i - 1 > 45, repeat steps (8,9,10)
8) s = s + s                - double the word
9) print(s[p*i - 1])
10) i = i + 1

******************************************************************************************

9 comments:

  1. plss upload the algorithm also

    ReplyDelete
  2. Replies
    1. The solutions are updated. Do check out.

      https://myskillrack.blogspot.in/2017/08/pps-4.html

      Delete
  3. print(s[p*i - 1])
    i cant understand this step.

    ReplyDelete
    Replies
    1. Assume some example by yourself and try to understand, You will get it.

      Delete
  4. Pankaj Sir Skillcopy has stopped working. Do something about it

    ReplyDelete
    Replies
    1. I'm really sorry. I can't help in this matter.

      Delete
  5. Bro plz upload solution of inlab 5

    ReplyDelete