Category Archives: Python Programming Language
Python Program Print Hollow Heart of Stars
Python Program Print Hollow Heart of Stars – This is a Python program that will print a Hollow Heart of stars. Source Code n = 6 for row in range(n): for col in range(n+1): if (row == 0 and col % 3 != 0) or (row == 1 and col % 3 == 0)… Read More »
Hollow Square of Stars Printing Python Program
Hollow Square of Stars Printing Python Program – This program will print a hollow square of stars in Python programming language. Here’s a Python program to print a hollow square: n = 5 for i in range(n): if i == 0 or i == n – 1: print(‘*’ * n) else: print(‘*’ + ‘ ‘… Read More »
Print Inverted Pyramid of Stars in Python
Python Different Counts in String
Python Different Counts in String – Python program to count uppercase letters, lower case letters, vowels, consonants and spaces in the given string. #Python program to count upper case letters, lower case letters #vowels, consonants and spaces in a string uppercase=0 lowercase=0 vowels=0 consonants=0 spaces=0 string=input(“Enter a String: “) for ch in string: if… Read More »
Python Function Circle Area
Python Function Circle Area – Write a Python program to input radius of a circle. Calculate the area of the circle with the given radius. Source code for Python Program to find Area of Circle # Python Function Area of Circle # Define the function to find area of circle def area_of_circle(radius): if radius <… Read More »
Python Program Check Positive Number
Python Program Check Positive Number – Write a Python program to input a number and check whether the given number is positive, negative or zero. Use Python if-elif-else construct. Python Program Check Positive, Negative or Zero Number # Python program to check a number # for positive, negative or zero num = int(input(‘Enter a number:… Read More »
Python Square Root Program
Python Square Root Program – Write a Python Program To find Square root of a number. Three Python programs to find square root of a number using Python. Code of Python Square Root Programs Program 1:Use Exponentiation Operator Exponentiation Operator ** in Python is used to raise the first operand/number to power of second number.… Read More »
Python GCD Recursive Function
Python GCD Recursive Function – Write a Python Program to find GCD of two numbers by recursion. Python GCD Recursive Function Python Program GCD of Two Numbers # Write a Python Program to find GCD # of two numbers using Recursion # define a recursive GCD function def recursive_gcd(a,b): if(b==0): return a else: return recursive_gcd(b,a%b)… Read More »
Python Power Recursive Function
Python Power Recursive Function – Write a Python program that uses recursion concept to calculate a number N raised to the power P. Python Recursive Function Power # Write a Recursive Function power_recursive(n,p) # to calculate n raised to power p. # define function def power(n, p): if p == 0: return 1 else:… Read More »