Python Program to Print Hollow Mirrored Half Diamond Star Pattern

Write a Python Program to Print Hollow Mirrored Half Diamond Star Pattern using a for loop, while loop, and functions. This example uses the nested for loop to iterate and print the Hollow Mirrored Half Diamond Stars pattern. rows = int(input(“Enter Hollow Mirrored Half Diamond Pattern Rows = “)) print(“Hollow Mirrored Half Diamond Star Pattern”) … Read more

Python Program to Print Triangle Pattern

This blog post shows how to write a Python Program to Print Triangle Pattern of Numbers, stars, and Alphabets (characters) using for loop, while loop, and functions with an example. Python Program to Print Triangle Star Pattern This program accepts the user input rows and uses the nested for loop to print the triangle pattern … Read more

Python Program to Make a Simple Calculator

Write a Python program to make a simple calculator that can perform addition, subtraction, multiplication, and division based on the user selected option. Python Program to Make a Simple Calculator The below program prints a message about each option and their respective numbers. Here, option 1 = Add, 2 = Subtract, 3 = Multiply, and … Read more

Python Program to Find Sum of 10 Numbers and Skip Negative Numbers

Write a Python program to find sum of 10 numbers and skip negative numbers. In this Python example, for loop range allows entering 10 numbers, and the if condition checks whether there are any negative numbers. If True, continue statement will skip that number from adding to posSum variable. posSum = 0 print(“Please Enter 10 … Read more

Python Program to Read 10 Numbers and Find their Sum and Average

Write a Python program to read 10 numbers and find their sum and average. In this Python example, for loop range iterates from 1 to 10 and read user entered 10 numbers and finds the sum while entering. Next, we divide that sum by ten to get the average. Sum = 0 print(“Please Enter 10 … Read more

Python Program to Print List Items in Reverse Order

Write a Python program to print list items in reverse order. In this programming language, we can use list slicing with a negative value to reverse the list items or use the list reverse method. a = [4, 7, 9, 11, 22, 44, 59] print(‘Printing the List Items in Rererse’) print(a[::-1]) a.reverse() print(‘\nPrinting the List … Read more

Python Program to Print List Items at Odd Position

Write a Python program to print list items at the odd position or odd index position. In this example, we use the list slicing starts at 0, incremented by 2, and ends at list length (end of the list). odList = [2, 4, 7, 11, 14, 22, 19, 90] print(‘Printing the List Items at Odd … Read more

Python Program to Print List Items at Even Position

Write a Python program to print list items at even position or even index position. In this Python even position example, the list slicing starts at 1, ends at the list end, and is incremented by 2. evList = [3, 6, 9, 11, 13, 15, 17, 19] print(‘Printing the List Items at Even Position’) print(evList[1:len(evList):2]) … Read more

Python Program to Print Array Elements in Reverse Order

Write a Python program to print array elements in reverse order.  In this example, the list slicing with negative value prints the numpy array elements in reverse order. import numpy as np arr = np.array([15, 25, 35, 45, 55, 65, 75]) print(‘Printing the Array Elements in Reverse’) print(arr[::-1]) print(‘\nPrinting the Array Elements’) print(arr) In this … Read more