Skip to main content

Python Program to Find Out the Maximum of Three Numbers

 

Competitive Programming Questions of Python

Python code to find out the maximum of three numbers.

If you are looking for Python Tutorial then it's here.



def max(n1,n2,n3):
    def max2(n1,n2):
        if n1>n2:
            return n1
        else:
            return n2
    return max2(max2(n1,n2),n3)

def main():
    n1 = int(input('Enter first Number: '))
    n2 = int(input('Enter second Number: '))
    n3 = int(input('Enter third Number: '))
    maximum = max(n1,n2,n3)
    print('Maximum number is ',maximum)

main()

When you run the above code. The output will be:


Enter first Number: 65
3Enter second Number: 2
Enter third Number: 98
Maximum number is  98

Comments

Popular posts from this blog

Popular Datasets for Data Analysis and Visualization (Beginner to Advance)

  Dataset IPL Dataset Download Now Unicorn Startups Dataset Download Now Indian Stock Market IPOs Dataset Download Now Courseras Dataset Download Now Marvel vs DC Dataset Download Now Disney Plus Dataset Download Now More Dataset links will be available soon.

Find String Of Maximum length Inside A String Sentence Using Python For Loop

  Small Python Program For Beginners To Practice In this article, we are going to write a Python Code to Print out the maximum string of length inside a string. For this, first, we break the string sentence at the space and then proceed with the code. If you are looking for a Python Tutorial series then it's here example = "Hello My name is Ninza and I am a developer" x = example.split(' ') print(x) print(len(x)) max_len = -1 for element in x: if len(element) > max_len: max_len = len(element) response = element print(response) The output of the code is: ['Hello', 'My', 'name', 'is', 'Ninza', 'and', 'I', 'am', 'a', 'developer'] 10 developer

Print Fibonacci Series In Python Using For Loop

  Fibonacci Series Using Python For Loop In this article, we are going to print the Fibonacci series Using Python For loop. This term of the series is the sum of two predecessor terms of the series. That's why it goes like, 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. If you are looking for a Python Tutorial Series then it's here def number(n): a = 0 b = 1 sum = 0 for count in range(1,n+1): print(sum, end=' ') count +=1 a = b b = sum sum = a+b print() number(10) The output of the code is: 0 1 1 2 3 5 8 13 21 34

Hollow Hour Glass or Hollow Sand Glass Program in Python

  Small Python Program For Beginners To Practice In this article, we are going to write python code to print out hollow hour glass as shown in the featured Image. If you are looking for a Python Tutorial series then it's here The python code we are going to write is a combination of normal hollow pyramid and Inverted hollow pyramid . we are going to combine both of them to get the desired output. def sand(n): for i in range(1, n+1): for j in range(1, i): print(" ", end="") for j in range(1, (n*2 - (2*i - 1))+1): if i == 1 or j == 1 or j ==(n*2 -(2*i-1)): print("*", end="") else: print(" ", end="") print() for i in range(2,n+1): for j in range(n-i): print(" ", end="") for j in range(1, (2*i-1)+1): if i == n or j == 1 or j == (2*i-1): print(&#

Mirror Number Pyramid in Python

Small Python Program For Beginners  In this article, we are going to write code to print out the mirror numbered pyramid using Python Programming. You can see that in the above-featured Image. If you are looking for a Python Tutorial Series, then it's here def triangle(n): for i in range(n): for j in range(n-i-1): print(" ",end=' ') for k in range(i,1,-1): print(k, end=' ') for l in range(1, i+1): print(l,end=' ') print('') triangle(10) The output of the program is: 1 2 1 2 3 2 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 5 6 5 4 3 2 1 2 3 4 5 6 7 6 5 4 3 2 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9

Write a program to print reverse counting from 10 to 1 using while loop in Python

  Python For Beginners to Practice In this article, we are going to write a Python program to print numbers in reverse order using a while loop.  First, we will print the reverse count of numbers 10 to 1. Then we will write a program to print the reverse of the numbers using the user's input. If you are looking for a python tutorial series then it's here count = 10 while True: print(count) count -= 1 if count == 0: break else: pass The output of the code is: 10 9 8 7 6 5 4 3 2 1 If you want to take input of integer from the user then you can do this using the following way: count = int(input("Enter the number: ")) while True: print(count) count -= 1 if count == 0: break else: pass The output of the code is: Enter the number: 20 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Python Code To Check If The Year Is A Leap Year

  Python Competitive Programming Questions In this article, We are going to write a python code to check if the input year is leap year or not. If you are looking for a Python Tutorial then it's here def CheckYear(year): if (year%4 == 0) and (year%100 != 0) or (year%400 == 0): print(year, ' is a leap year') else: print(year, ' is not a leap year') def main(): year = int(input('Enter the number of rows: ')) CheckYear(year) main() The output of the code is: Enter the number of rows: 2021 2021 is not a leap year Enter the number of rows: 2000 2000 is a leap year Enter the number of rows: 2019 2019 is not a leap year

Python Hour Glass (Sand Glass) Program In Python

  Small Python For Beginners to Practice In this article, we are going to print a Sandglass star pattern using Python as you can see in the featured image. If you are looking for a Python Tutorial Series then it's here If you look closely then this Hourglass pattern is a combination of a normal pyramid and inverted pyramid program in Python. So we will combine both of these programs to print out the Hourglass star pattern. def glass(rows): spaces = 0 stars2 = 3 spaces2 = rows-2 stars = 2*rows-1 for i in range(1, rows+1): print(' ' * spaces + '*' * stars) stars -=2 spaces +=1 for i in range(1, rows): print(' '*spaces2 + '*'*stars2) stars2 += 2 spaces2 -= 1 glass(10) The output of the program is: ******************* ***************** *************** ************* *********** ********* ******* ***** *** * ***

Equilateral Triangle or Pyramid Pattern In Python

Competitive Programming Questions In Python   In this article, we are going to draw the equilateral triangle type pattern using Python Programming Language. If you are looking for a Python Tutorial Series then it's here def equilateral(n): stars = 1 spaces = n-1 for i in range(1, n+1): print(' '*spaces + '*'*stars) stars += 2 spaces -= 1 equilateral(10) The output of the code is: * *** ***** ******* ********* *********** ************* *************** ***************** *******************

Triangle: Alphabet Pattern in Python Programming Part(3)

  Competitive Programming In Python In this article, we are going to print out the Alphabet Pattern in Python. If you are looking for a Python Tutorial Series then it's here Before we jump into the code, let's first understand ASCII value and ASCII character ASCII Characters ASCII Value A-Z 65-90 a-z 97-122 0-9 48-57 Spceial Symbols 0-47, 58-64, 91-96, 123-127 The Code Part: def alphabet(n): asciiValue = 65 for i in range(asciiValue, asciiValue+n+1): alpha = i for j in range(asciiValue, i+1): print(chr(alpha), end="") alpha +=1 print() alphabet(6) The output of the code is: A BC CDE DEFG EFGHI FGHIJK GHIJKLM