[go: up one dir, main page]

0% found this document useful (0 votes)
27 views7 pages

Notespython

Uploaded by

badoni.sanjay1
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)
27 views7 pages

Notespython

Uploaded by

badoni.sanjay1
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/ 7

#name = "naman"

#print(name)
#print(type(name))
#here name is a string,which means it is a series of characters
#the 3rd statement will result in string

#first_name = "naman"
#last_name = "badoni"
#full_name = first_name + " " + last_name
#print(full_name)
#print("hello you're name is "+ full_name +" "+"you're age is 16")
#many strings can be compiled in a single string as in statement 9
#+ sign should be there after the quotation sign in the print command

#age = 21
#age +=19
#age = age + 19
#print(age)
#print (type(age))
#print("your age is:"+ str(age))
#here age is int, we used integer instead of strings because strings cannot be used
in mathematical operations , which means avoid using quotation sign
#statement 16 and 17 does the same command but statement 16 is much efficient
#In the statement 20 str() is used to covert the integer type data into string type
data otherwise it would show error as int cannot be used in statements

#length = 25.5
#print(length)
#print(type(length))
#print("the length of your room is " + str(length) + "cm")
#the statement 27 will result in float value
#float means the data which contains integer with a decimal value and integer
couldn't work with decimal values

#human = True
#print(human)
#Booleans are used for true and false and are useful in if statements

#multiple assignment helps us to use many variables at a same time


#name = "naman"
#age = 16
#neutral = True
#name, age, neutral = "naman", 16, True
#print(name)
#print(age)
#print(neutral)
#print(name, age, neutral)
#X = 70
#Y = 70
#X = Y = 70
#print(X , Y)

#name = "Naman "


#print(name.capitalize())
#print(len(name))
#print(name.lower())
#print(name.upper())
#print(name.find("n"))
#print(name.isdigit())
#print(name.isalpha())
#print(name.count("a"))
#print(name.replace("a","o"))
#print(name*4)

#typecasting = convert the data type of a value to another data type


#x = 2 #int
#y = 2.0 #float
#z = "4" #string
#y = int(y) / float(y)/ str(y)
#print(type(y))

#name = input("what is your name? : ")


#print("hello "+ name + ",welcome to our website")

#age = int(input("what is your age? : "))


#print("hello "+ name +", your age is "+ age)

#age = age + 1
#print(age)
#print("hello,you are "+str(age)+ " years old")

#slicing = create a substring by extracting elements from another string


# indexing[] or slice()
# [start:stop:step]
#indexing = a way to access individual element in a sequence such as string
#name = "naman badoni"
#first_name = name[0]
#print(first_name)
#In this case only one character is in the output which is n from naman
#first_name = name[0:5]
#print(first_name)
#here we chose 5 instead of 4 in the 88th statement because 4 is exclusive and that
will result in nama only
#we can also leave start in sqaure bracket, so python will automatically assume it
as zero
#last_name = name[6:]
#print(last_name)
#step function helps in skipping the characters present in the string
#example = name[::2]
#print(example)
#if revesing our name then,
#reversed_name = name[::-1]
#print(reversed_name)

#slice
#website = "http://google.com"
#slice = slice(7,-4)
#print(website[slice])

#if statement = a block of code if the condition is true


#age = int(input("what is your age ?"))
#print("you are "+ str(age)+ " years old")
#if age >= 18:
# print("you are an adult!")
#elif age < 0:
# print("you haven't been born yet!")
#else:
# print("you are a child!")

#logical operators (and,or,not)= used to check if two or more conditional statement


are true
#temp = int(input("today temperature in your area is : "))
#if temp >= 0 and temp <= 30:
# print("the temperature is bad")
# print("dont go outside")
#elif temp > 0 or temp < 30:
# print("the temperature is good! ")
# print("go outside")

# while loop = a statement that will excecute its block of code, as long its
condition remains true
#name = ""
#while len(name) == 0:
#name = input("enter your name : ")
#print("helloo " + name )

#for loop = a statement that will excecute its block of it for a limited number
#while loop = unlimited
#for loop = limited
#for index in range(2,100,2):
#print(index)
#for i in "naman badoni":
# print(i)

#import time
#for seconds in range(10,0-1,-1):
# print(seconds)
# time.sleep(1)
#print("happy birthday")

#nested loop = the "inner loop" will finish all of its iterations before finishing
one iteration of the outer loop
#rows = int(input("How many rows do you want? : "))
#column = int(input("How many column do you want? : "))
#symbol = input("which symbol do you want to you? : ")
#for i in range(rows):
#for j in range(column):
#print(symbol, end="")
#print("")

#loop control statement = change a loops execution from its normal sequence
#break = used to terminate the loop entirely
#continue = skips to next iteration of loop
#place = does nothing, acts as placeholder

#while True: {we can write 1==1 instead of True}


#name = input("what is your name? ")
#if name != "":
#break

#SYMBOL = input("which sybol do you want to use?: ")


#def triangle(n):
#for i in range(n):
#for j in range(i+1):
#print(SYMBOL,end="");
#print()
#triangle(5)

#phone_number = "123-123456"
#for i in phone_number:
#if i == "-":
#continue
#print(i,end="")

#for i in range(1,21):
#if i == 13:
#pass
#else:
#print(i)

#lists = used to stored multiple items in single variable


#grocery = ["oil","tea","pulses"]
#grocery[0] = "honey"
#print(grocery[0])
#for x in grocery:
#print(x)

#2D list = lists in list


#dinner = ["pizza","hamburger","chicken",]
#drinks = ["coffee","cold drink","tea"]
#dessert = ["ice cream","custurd",]
#food = [dinner,drinks,dessert]
#print(food[0][0])

#tupules = collection which is ordered and unchangeable


# used to group together related data
#students = ("naman",16,"male")
#print(students.count("male"))
#print(students.index("naman"))
#for i in students:
#print(i)
#if "naman" in students:
#print("naman was here")

#set = which is undefined, unindexed.No duplicate values


#utensils = {"fork","knife","spoon"}
#dishes = {"cups","bowls","plate","spoon"}
#dishes.update(utensils)
#print(dishes.union(utensils))
#print(dishes.intersection(utensils))
#print(dishes.difference(utensils))
#print(dishes)
#for i in dishes:
#print(i)

#import math
#n = 5
#print("the factorial of 5 is:", )
#print(math.factorial(n))

#tuples = collection which is ordered and unchangeable

#student = ("naman",16,"male")
#x = student.count("naman")
#print(x)
#y = student.index("male")
#print(y)
#for x in student:
#print(x)
#if "naman" in student:
#print("Naman is present")

#dictionary = a changeable, unordered collection of unique key


#capitals = {'India':'Delhi','USA': 'Washington DC','China':'Beijing'}
#print(capitals['USA'])
#print(capitals.get('Germany'))
#print(capitals.keys())
#print(capitals.values())
#print(capitals.items())

#for key,value in capitals.items():


#print(key,value)

#capitals.update({'Germany':'Berlin'})
#print(capitals)
#capitals.pop('China')
#print(capitals)

#functions = a block of code which is executed only when it is called

#def hello(name,age):
#print("hello"+name)
#print("your age is "+str(age))
#hello("naman",16)

#return = function send bach value/object back to the caller

#def multiply(number1,number2):
# return number1*number2
#x = multiply(6,4)
#print(x)

#keyword arguement...
#def name(first,middle,last):
# print("His name is ",first," ",middle," ",last )
#name(last="mukesh",middle="nitin",first="Neil")

#nested function loop


#print(round(abs(float(input("enter a whole number:")))))

# *args

#def add(*args):
#sum = 0
#for i in args:
# sum += i
#return sum
#print(add(1,2,3,4))

#str.format...
#x = "Naman"
#y = 16
#print("{}'s age is {} ".format(x,y))

#import random
#x = random.randint(1,6)
#y = random.random()
#mylist = ["rock","paper","scissors"]
#z = random.choice(mylist)
#print(z)

#import random
#cards = [1,2,3,4,5,6,7,8,9,"J","K","Q","A"]
#random.shuffle(cards)
#print(cards)

#exception = events detected during execution that interrupt the flow of program
#try:
#n = int(input("enter a number you want to divide:"))
#d = int(input("enter a number you want to divide with:"))
#result = n/d
#print(result)

#except ZeroDivisionError as e:
#print (e)
#print("can't divide by 0")

#except ValueError as e :
#print (e)
#print("please enter the right input")

#except Exception as e :
#print (e)
#print("Something went wrong:(")

#finally:
#print("this will always be there")

#import os
#path = "C:\\Users\\Sanjay Badoni\\OneDrive\\Desktop\\language\\
pythoncalculator.py"
#if os.path.exists(path):
#print("yes")
#else :
#print("no")

#with open('C:\\Users\\Sanjay Badoni\\OneDrive\\Desktop\\language\\


pythoncalculator.txt') as file:
# print(file.read())

#text = "hello \n this is some text"


#with open('test.txt','w') as file: #a=append
#file.write(text)

#import shutil
#shutil.copyfile('x',y)#file path/location
#shutil.copy()
#shutil.copy2()

#import os
#source = "x"#file path is required here
#destination = "y"#another file path is requred here

#try:
#if os.path.exists(destination):
#print("file already exists")
#else :
#os.replace(source,destination)
#print("file has been moved")
#except FileNotFoundError:
#print(source+"was not found")

#import os
#import shutil
#os.remove('x')#file path
#os.rmdir('x')#folder path
#shutil.rmtree(path)#removes the whole file and the data present in it

You might also like