0% found this document useful (0 votes)
9 views3 pages

Python Basics and Functions Guide

Print (max (3,4)) outputs 4, showing how to find the maximum of numbers. Math functions like floor, ceil, sqrt can be accessed from the math module. Input allows getting user input and storing in variables. Lists can be joined using extend and elements inserted, removed, or found with methods like insert, remove, index. Tuples are immutable lists that cannot be modified. Functions like say_hi and cube demonstrate defining and calling functions. Conditional statements like if/else and if/and are used to check conditions. A calculator program uses input, operators, and conditionals to evaluate expressions. While loops repeat code until a condition is met.

Uploaded by

Akhilesh Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Python Basics and Functions Guide

Print (max (3,4)) outputs 4, showing how to find the maximum of numbers. Math functions like floor, ceil, sqrt can be accessed from the math module. Input allows getting user input and storing in variables. Lists can be joined using extend and elements inserted, removed, or found with methods like insert, remove, index. Tuples are immutable lists that cannot be modified. Functions like say_hi and cube demonstrate defining and calling functions. Conditional statements like if/else and if/and are used to check conditions. A calculator program uses input, operators, and conditionals to evaluate expressions. While loops repeat code until a condition is met.

Uploaded by

Akhilesh Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python notes

Print (max (3,4)) for 4


Same can be applied as
Min
Round
Abs for absolute negative will become positive
% between 3 numbers for the remainder

For more math functions


from math import *

print(floor(3.7))= 3
similar ceil for opposite
sqrt for squire root

for take the input from the customer


name = input("Enter you name: " )
age = input("Enter you age: " )
print("Hello " + name+ "! you are " +age+ " year old")

Joining two lists


lucky_numbers = ["2","35","35", "33"]
friends= ["hero","zero","ajay","raju", "viraj"]
[Link](lucky_numbers)
print(friends)

we can use [Link] to add the new friend in the list but it will
add in the end only
to add in between we can use
[Link](1,”Dinesh”) where 1 shows position and second friends
name
[Link](“name”) to remove the specific friends and
[Link] to delete all the friends
[Link]() to remove last person of the list

print([Link](“name”)) it gonna tell index of the person


print([Link](“name”)) to know the number of same name in the
list.
print([Link]()) to short the list according to name
friends2 = [Link]()
Tuple
coordinates= (4,5)
print(coordinates)
in list
coordinates= [4,5]
coordinates[1] = 15
print(coordinates)

the main difference in tuple and list is that data in tuple cannot be
changes but can be done in case of list.

functions
def say_hi(name, age):
  print("Hello " + name + ", you are " + age +",")

say_hi("mike", "35")
say_hi("hero", "15")

def cube(num):
  return num*num*num

print(cube(5))

if statement
is_Nidhi = True
is_Neha = False

if is_Nidhi or is_neha:
  print("You are great women")
else:
  print("you r bad women")

if and or statement
is_Nidhi = True
is_Neha = False

if is_Nidhi and not(is_Neha):
  print("you are my women")
elif not(is_Nidhi) and is_Neha:
  print("you are my Di")

else:
  print("you r bad women")

Calculator of better level


num1 = float(input("Enter your first number: "))
op = input("Enter your first number: ")
num2 = float(input("Enter your second number: "))

if op == "+":
  print(num1 + num2)
elif op == "-":
  print(num1 - num2)
elif op == "*":
  print(num1 * num2)
elif op == "/":
  print(num1 / num2)
else:
  print("Invalid input")

while loop

You might also like