PythonPrograms

Question 1 Number Pattern

Print the following pattern for n number of rows. For eg. N = 5

1 1 12 21 123 321 1234 4321 1234554321

Ques 2 Reverse Every Word

Given a string S, reverse each word of a string individually. For eg. if a string is "abc def", reversed string should be "cba fed".

Input Format : String S

Output Format : Updated string

Sample Input : Welcome to Hacktober Hackathon

Sample Output: emocleW ot rebotkcaH nohtakcaH

Ques 3 All prime numbers

Given an integer N, print all the prime numbers that lies in between 2 to N (both inclusive). Print the prime numbers in different lines.

Input Format : Integer N

Output Format : Prime number in different lines

Sample Input : 9

Sample Output : 2 3 5 7

Ques 4 Decimal to Binary

Given a decimal number (integer N), convert it into binary and print. The binary number should be in the form of an integer. Note : The given input number could be large, so the corresponding binary number can exceed the integer range. So take the answer as long.

Input format : Integer N

Output format : Corresponding Binary number (long)

Sample Input 1 : 12

Sample Output 1 : 1100