Day: March 10, 2021

Python Example – Write a Python program to construct the following pattern, using a nested loop number

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to construct the following pattern, using a nested loop number.   Sample Solution: Python Code: for i in range(10): print(str(i) * i) Sample Output: 1 22 333 4444 55555 666666 7777777 88888888 999999999     Write a Python program to construct …

Python Example – Write a Python program to create the multiplication table (from 1 to 10) of a number

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to create the multiplication table (from 1 to 10) of a number.   Sample Solution: Python Code: n = int(input(“Input a number: “)) for i in range(1,11): print(n,’x’,i,’=’,n*i) Sample Output: Input a number: 5 5 x 1 = 5 5 x …

Python Example – Write a Python program to calculate the sum and average of n integer numbers

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to calculate the sum and average of n integer numbers (input from the user). Input 0 to finish.   Sample Solution: Python Code: print(“Input some integers to calculate their sum and average. Input 0 to exit.”) count = 0 sum = …

Python Example – Write a Python program to find the median of three values

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to find the median of three values.   Sample Solution: Python Code: a = float(input(“Input first number: “)) b = float(input(“Input second number: “)) c = float(input(“Input third number: “)) if a > b: if a < c: median = a …

Python Example – Write a Python program to display astrological sign for given date of birth

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to display astrological sign for given date of birth.   Sample Solution: Python Code: day = int(input(“Input birthday: “)) month = input(“Input month of birth (e.g. march, july etc): “) if month == ‘december’: astro_sign = ‘Sagittarius’ if (day < 22) …

Python Example – Write a Python program that reads two integers representing a month and day and prints the season for that month and day

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program that reads two integers representing a month and day and prints the season for that month and day.   Sample Solution: Python Code: month = input(“Input the month (e.g. January, February etc.): “) day = int(input(“Input the day: “)) if month …

Python Example – Write a Python program to check a triangle is equilateral, isosceles or scalene

(Python Example for Citizen Data Scientist & Business Analyst)   Write a Python program to check a triangle is equilateral, isosceles or scalene. Note : An equilateral triangle is a triangle in which all three sides are equal. A scalene triangle is a triangle that has three unequal sides. An isosceles triangle is a triangle …