• info@introtallent.com
  • +91 8431610064
Introtallent
  • Courses
    • Data Science PRO [OFFLINE]
    • Data Science PRO [Live Online]
    • Analytics PRO [Live Online]
    • AI Engineer Certificate [Live Online]
  • Hire From Us
  • Student
    • Download Android App
    • Resources
      • SQL Interview Questions
      • Tableau Interview Questions
      • Power BI Interview Questions
      • Excel Interview Questions
      • Python Interview Question
    • LMS Login
  • Login
  • |
  • Sign up
    • Login
    • Sign up

Python Programming – Fundamental codes for logic development

  • April 1, 2021June 4, 2023
#Python program to find the max of 2 nmbers (using if)


a=int(input("Enter first number: "))
b=int(input("Enter second number: "))

if a>b:
print(a,'is the greater number')

elif b>a:
print(b,'is the greater number')

else:
print('Both the numbers are same')

 

#Python program to find the max of 2 numbers (using function)

a=int(input("Enter first number: "))
b=int(input("Enter second number: "))

if a==b:
print('Both the numbers are same')
else:
print(max(a,b),'is the greater number')

 

#Python program to find the max of 2 numbers (using lambda function)

#A lambda is an anonymous function, and it takes any number of

#arguments. But the expression is only one.

a=int(input("Enter first number: "))
b=int(input("Enter second number: "))

if a==b:
print('Both the numbers are same')

else:
big_num = lambda a,b:a if a > b else b
print(big_num(a,b),' is the greater number')

 

# Python program to find the largest of 3 numbers

a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
c=int(input("Enter third number: "))

if a==b==c:
print('Same number')

elif a>b>c:
print(a,"is the largest number")

elif b>a>c:
print(b,"is the largest number")

elif c>b>a:
print(b,"is the largest number")

 

# Python program to find the largest (using user defined function)

def max_of_three(a, b, c):
if (a>b) and (b>c):
largest = a

elif (b>a) and (b>c):
largest = b

else:
largest = c
return largest

#---------- end of function ------------

print(max_of_three(10,30,20))
print(max_of_three(23,7,12))

 

# Python program to find the largest (using max function)

#number inputs
a=int(input("Enter first number: "))
b=int(input("Enter second number: "))
c=int(input("Enter third number: "))

#check if the numbers are same
if a==b==c:
print('Same number')
else:
#print largest using max function
print(max(a,b,c),'is the largest number')

 

#Print multiplication table
n=int(input('Enter a number to print the multiplication table:'))
for i in range(1,11):
print(n,'*',i,'=', n*i)

 

#Print multiplication table (horizontal output)

n=int(input('Enter a number to print the multiplication table:'))
for i in range(1,11):
print(n*i, end=' ')

 

#Print multiplication table in a given range (horizontal output)

x=int(input('Enter the minimum value of the range:'))
y=int(input('Enter the maximum value of the range:'))

for i in range(x,y+1):
for j in range(1,11):
print(i*j, end='\t')
print()

 

#Print multiplication table in a range (side by side)

x=int(input('Enter the minimum value of the range:'))
y=int(input('Enter the maximum value of the range:'))

for i in range(1,11):
for j in range(x,y+1):
print(i*j,end='\t')
print()

 

#print the first letter of each of the words using list comprehension

#List comprehension is used to perform some operation for every element
# or select a subset of elements that meet a condition.

s='Python is a programming language'
my_list= [word[0] for word in s.split()]
print(my_list)

 

#print the first letter of each of the words
s='Python is a programming language'
my_list = []

for word in s.split():
my_list.append(word[0])

print(my_list)

Share this:

  • Facebook
  • X

Related

Tags: Data Science Programming Programming concepts Python

Post navigation

Next Post

Related Posts

  • Understanding the Differences Between Data Science and Data Analytics
    December 17, 2024
  • Key Data Science and AI Trends to Watch in 2025
    November 5, 2024
  • Mastering the XLOOKUP Function in Excel: Step-by-Step
    June 2, 2024
  • The Rise of AI in Business Analytics For Decision-Making
    May 11, 2024
  • What Is Generative AI And How Does It Work? A Comprehensive Guide
    April 12, 2024
  • Machine Learning: A Beginner’s Guide to Understanding the Basics
    April 12, 2024
  • 9 Steps for Crafting an Ultimate Data Scientist Resume
    March 16, 2024
  • Data Science Career Opportunities: Your Guide To Unlock Top Data Scientist Jobs
    December 31, 2023
  • Best Career Options After Pursuing Data Science Course
    December 30, 2023
  • Harness the Power of Data with Six Captivating Tableau Projects
    December 29, 2023
  • Definitive List of Top 10 Data Science Tools
    December 28, 2023
  • Top 15 Data Science Interview Questions You Must Nail!
    November 30, 2023
  • How to Become a Data Scientist in Bangalore?
    November 30, 2023
  • Impact of Data Science in Business and Its Uses
    November 30, 2023
  • Essential Role of Data Scientist in Today’s Tech Landscape
    November 30, 2023
  • 5 Transformative Benefits of Tableau Certification to Boost Career
    October 24, 2023
  • Types of Artificial Intelligence Categories You Must Familiarize With
    October 23, 2023
  • Exploring the Need for Data Science and AI Experts in 2023
    October 20, 2023
  • What Does a Data Analyst Do: Roles, Skills, and Salary?
    October 20, 2023
  • 5 Key Reasons Why Data Analytics is Important to Business
    September 26, 2023
  • Elevate Your Career with Data Science Jobs: A Complete Guide
    September 26, 2023
  • Is AI Engineering a Good Career Option in 2023 ?
    September 26, 2023
  • Ultimate Guide to Statistical Analysis for Data Science
    September 16, 2023
  • What is Data Science – A complete overview with future
    August 15, 2023
  • Power BI Interview Questions and Answers
    August 3, 2023
  • Top 50 Data Science Interview Questions with Answers
    September 7, 2022
  • Excel Interview Success: Top 40 Questions and How to Answer Them
    July 5, 2022
  • SQL Interview Questions with Answers – An Ultimate Guide
    June 20, 2022
  • 12 Must Know Problem Solving Questions Asked in Analytics Interview
    May 8, 2022
  • 17 Ultimate Non-Tech Interview Questions to Empower Your Career Path
    May 2, 2021

Introtallent

Best Data Science
training institute
in Bangalore.

Follow Us

Contact Us

  • #10, 1st Floor,
    12th Cross, CMH Road, Indiranagar, Bangalore 560037

  • info@introtallent.com

  • +91 843 161 0064

Feel free to contact us.
  • About Us
  • Analytics PRO
  • Analytics Training
  • Artificial Intelligence Course
  • Blog
  • Data Science and Analytics Jobs
  • Data Science PRO
  • Hire from us
  • Home
  • Introtallent in News
  • Introtallent Placements
  • Privacy Policy
  • Student Registration
  • Tableau Course
 © 2017-2024 Introtallent . All Rights Reserved