Que-1. Write a program to display product of the digits of a number accepted from the user. num = int(input("Enter any number : ")) temp = num product = 1; while(temp != 0): product = product * (temp % 10); # Remove last digit from temp. temp = int(temp / 10) print("\nProduct of all digits in", num, ":", product) Que-2. Write a program to find the sum of the digits of a number accepted from user. n=int(input("Enter a number:")) tot=0 while(n>0): dig=n%10 tot=tot+dig n=n//10 print("The total sum of digits is:",tot) Que-3. Write a program to check whether a number is prime or not. num = int(input("Enter a number: ")) flag = False if num > 1: for i in range(2, num): if (num % i) == 0: flag = True break if flag: print(num, "is not a prime number") else: print(num, "is a prime number") Que-4. Write program to print the following pattern. a) 1 1 2 1 2 3 1 2 3 4 rows = int(input("Enter the number of rows: ")) for i in range(1, rows+1): for j in range(1, i + 1): print(j, end=' ') print("") b) * * * * * * * * * * rows = 4 for i in range(rows + 1, 0, -1): for j in range(0, i - 1): print("*", end=' ') print(" ") Que-5. Accept 10 numbers from the user and display their average. num = int(input('How many numbers: ')) total_sum = 0 for n in range(num): numbers = float(input('Enter number : ')) total_sum += numbers avg = total_sum/num print('Average of ', num, ' numbers is :', avg) Que-6. Write a program to display all the numbers which are divisible by 13 but not by 2 between 100 and 500. Que-7. Write a program to print the following pattern 5 5 5 5 5 4 4 4 4 3 3 3 2 2 1 rows = 5 for i in range(rows, 0, -1): num = i for j in range(0, i): print(num, end=' ') print("\r") Que-8. Write a program to accept decimal number and display its binary number. def decimalToBinary(n): return bin(n).replace("0b", "") if __name__ == '__main__': print(decimalToBinary(8)) Que-9. Accept a number from user and check whether it is palindrome or not. num=int(input("Enter a number:")) temp=num rev=0 while(num>0): dig=num%10 rev=rev*10+dig num=num//10 if(temp==rev): print("The number is palindrome!") else: print("Not a palindrome!") Que-10.Write a program to accept a number and check whether it is a perfect number or not. n = int(input("Enter any number: ")) sum1 = 0 for i in range(1, n): if(n % i == 0): sum1 = sum1 + i if (sum1 == n): print("The number is a Perfect number!") else: print("The number is not a Perfect number!") Que-11. Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word def lengthOfLastWord(a): l = 0 x = a.strip() for i in range(len(x)): if x[i] == " ": l = 0 else: l += 1 return l if __name__ == "__main__": inp = "Gajendra Singh Thakur " print("The length of last word is", lengthOfLastWord(inp)) Que-12. Mr. John is making a website, in which there is a tab to create a password. As other websites, there are rules so that the password gets complex and none can predict the password for another. So he gave some rules like: 1. At least one numeric digit 2. At Least one Small/Lowercase Letter 3. At Least one Capital/Uppercase Letter 4. Must not have space 5. Must not have slash (/) 6. At least/Minimum 6 characters If someone inputs an invalid password, the code prints: “Invalid password, try again”. Otherwise, it prints: “password valid”. Input Format: A line with a given string as a password Output Format: If someone inputs an invalid password, the code prints: “Invalid password, try again”. Otherwise, it prints: “password valid”, without the quotation marks. Constraints: Number of character in the given string <=10^9 Sample input 1: abcDeF012 Sample output 1: password valid Sample input 2: abcDefGH Sample output 2: Invalid password, try again Note: Without using any pythons library like(re, string etc)