Notespython
Notespython
#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
#age = age + 1
#print(age)
#print("hello,you are "+str(age)+ " years old")
#slice
#website = "http://google.com"
#slice = slice(7,-4)
#print(website[slice])
# 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
#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)
#import math
#n = 5
#print("the factorial of 5 is:", )
#print(math.factorial(n))
#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")
#capitals.update({'Germany':'Berlin'})
#print(capitals)
#capitals.pop('China')
#print(capitals)
#def hello(name,age):
#print("hello"+name)
#print("your age is "+str(age))
#hello("naman",16)
#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")
# *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")
#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