0% found this document useful (0 votes)
4 views2 pages

Python Notes

The document provides an overview of basic Python programming concepts, including variable types (int, str, float, boolean) and string manipulation methods. It explains how to perform arithmetic operations, use if statements, and the importance of operator precedence. Additionally, it covers string formatting with f-strings and various string methods for manipulation.

Uploaded by

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

Python Notes

The document provides an overview of basic Python programming concepts, including variable types (int, str, float, boolean) and string manipulation methods. It explains how to perform arithmetic operations, use if statements, and the importance of operator precedence. Additionally, it covers string formatting with f-strings and various string methods for manipulation.

Uploaded by

junknotify
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

input(" ") - to prompt something on the screen

print("") - to print something on the screen


types of variable
int
str
float
boolean

python str
""
''
''' ''' - used for big messages
print(course[0])- returns characters from the string
print(course[-1])- returns characters from the end of the string
print(course[0:3])- returns characters from 0 position uptil two but excludes the 3
position,
print(course[:]) - returns from 0 to the whole string, can be used to make copies
of the string
print(course[0:])- returns the entire string,
print(1:-1) = returns characters from 1 position to the end of the string excluding
the last character
example
course= ("Python learning")
1. return = P
2. return = g
3. return = Pyt
4. return = Python learning

for formatted strings prefix the string with f'{first variable} [{second variable}]

len() = to find the length of the string


ex: print(len(variable))
variable.(methods) give various functions to strings
ex variable.lower()
variable.upper()
varialble.find()-function returns the index location of the requested character in
the string
variable.replace()= replaces the sepecified text in the brackets
find returns the index location
in operation provides a boolean value
eg for in operation "___" in variable
__________________________________________________________________________
ARITHMATIC OPERATION
Includes all mathematic operation
but for division there are two operations ("/" returns float value and "//" returns
integer value)
"%" modulus operator returns the remainder value
exponent operator is "**"
Operator Precedence
parenthesis
exponentiation
multiplication/division
addition/subraction

import math (basically import the math function module)


math.function

__________________________________________________________________________________
IF STATEMENTS

If variable:
printer("")
else
printer("")
else:
printer("")
elif variable
printer("")

__________________________________________________________
points to note:
-you can only concatenate str with +
-if using placeholder {} while printing start the statment with 'f'
-placeholder should be placed with the " "
for ex: print(f"New Price after down payment is ${new_price}")
_______________________________________________
and/or operator
not= converts true boolean value to false

You might also like