Posts

Showing posts from August, 2020

Ch 44 Fibonacci_seq jus for practice

 # if u want to print not in another line if u want print in one line so use this code to one line in " " anything u want type here for i in range(1,11): def fibonacci_seq(n): # to take a number we define (n) a=0 # a=0 b=1#b=0 if n==1: pirint(a) elif n==2: print(a,b) else: print(a,b,end =" ") for i in range(n-2): c=a+b a=b b=c print(c,end =" ") user=input("enter a num") user=int(user) print(fibonacci_seq(user)) #this chapter is not so impo this chapter for juat prctice and improve coding skils print(i ,end =" ")

Ch 43 is_palindrom reverse name is True or False

 #revers the word if name is pralindrom ==true else false def is_palindrom(word): new=word[::-1] if word == new: return True else: return False name=input("enter anyhig") print(is_palindrom(name)) #to reverse the word and anu numer we use [::-1] is impo see top to learn more #in short way to excute same program  def is_palindrom(word): if word == word[::-1]: return True return False print(is_palindrom("madam")) print(is_palindrom("horse")) #in very short way def is_palindrom(word): return word == word[::-1] print(is_palindrom("madam")) print(is_palindrom("horse"))

Ch 42 three number greater number game by def

 def bigger(a,b,c): if a>(b and c): return a elif b>(a and c): return b elif c>(b and a): return c num1=int(input("enter a num")) num2=int(input("enter a num")) num3=int(input("enter a num")) total =bigger(num1,num2,num3) print(f"{total} is grater number") #need help in def function form yt

Ch 41 greater number game

 def bigger(a,b): if a>b: return a else: return b num1=int(input("enter a num    ")) num2=int(input("enter a num    ")) greater=bigger(num1,num2) print(f"{greater}   is greater")

Ch 40 function practice

 #print last keywork by user inout def funtion def last(a): return (a[-1]) user=input("enter your name") print(last(user)) # odd even game def odd_even(num): if num%2==0: return "even" return "odd" user=int(input("enter a number")) print(odd_even(user)) #true and false game using def funtion def odd_even(num): if num%2==0: return True return False user=int(input("enter a num")) print(odd_even(user)) #without perameter the def funtion can work properly def song(): #u can see in this the perameter is not assing and the funtion can work properly return "happy birthday song" print(song()) #perameter = assing in def is called perameter #call==agument

Ch 39 print vs return

 def add_three(a,b,c): # in print funtion u dont neet to type print again print(a+b+c) add_three(5,5,5) #def funtion u must store in variable or print to show the result def add_three(a,b,c): return a+b+c print(add_three(5,5,5)) #in future program very meed for return not print

Ch 38 def function and function making process

 def add_two (a,b): #in python define we use def keyword to define a funtion return a+b #return funtion can return what u do funtion for task total=add_two(5,4) #if u want to print thr result u must store in variable u can use shrtcut for this print(total)  #print #u can also use this to short your program def add_two(a,b): return a+b print(add_two(9,1)) #for def input def add_two(num1,num2): return num1+num2 a=int(input("enter your first number")) b =int(input("enter your second number")) total=add_two(a,b) print(total) #for def input to add string to string def add_two(num1,num2): return num1+num2 a=input("enter your first name") b =input("enter your last name") total=add_two(a,b) print(total)

Ch 36 step argument in range function

 #for odd number increse the 2nd number to more number for i in range(1,11,2): print(i) #for even number for i in range(0,11,2): print(i) #for reverse number for i in range(-10,-0): print(i) #for no negitive sign for i in range(10,0,-1): print(i)

Ch37 only in python function

 #same as many computer laguage name = "ankit" for i in range(len(name)): print(name[i]) #only in python name=input("enter your name") for i in name: print(i) #input user add number using python only num=input("enter a number") total=0 for i in num: total+=int(i) print(total)

Ch 35 random number and DRY function

 #random number and DRY fucnction use #the impprt random is change number always you win #the function genrate random number import random winning_number=random.randint(1,100) number=int(input("guess a number between 1 to 100")) guess=1 game_over=False # remmenber_ this to run the program while not game_over: if number==winning_number: print(f"you win,you took {guess} times") game_over=True else: if number<winning_number: print("too low") else: print("too high") guess+=1 number=int(input("guess again"))# using DRY funtion to short the program line

ch=34 Modify the guess number game

 winning_number = 43 n=1 number = int(input("enter your number")) game_over = False    #False F is always capital if it is small the funtion is not work while not game_over: if number == winning_number: print(f"you win,you took {n} time") game_over=True # T always capital else: if number<winning_number: print("too low") n+=1 number=int(input("enter something")) else: print("too high") n+=1 number=int(input("enter something")) #Always remember the true T is always capital  #And true T is capital

Ch 33 break and continue

 for i in range(1,11): if i == 5: continue print(i) #Ye sirf 5 ko print nahi karega aur sabko karega for i in range(1,11): if i == 5: break print(i) #Ye sirf 4 tak hi print karega aur print nahi karega

Ch 32 for loop exercise

 for i in range(10): print("hello world") # the range function is help to define the range which number u want to print for i in range(10,30): #  print(f"hello world {i}") (10,30).  In this line u command to (start:stop) lekin ismai 0bhi count hoga toh ye sirf 29number tak dekhaga #The sum input exercisen int(input("enter something")) total=0 for i in range(1,n+1): total+=i print(total) #simple to learn and easy to use !! Exercise. 2  total=0 num=input("enter a number") for i in range(0,len(num)): total+=(int(num[i])) print(total) The code will add this type of formate ====# 1+2+3+4+5+6+7+8 Exercise 3 name=input("enter your name") temp="" for i in range(len(name)): if name[i] not in temp: print(f"{name[i]}:{name.count(name[i])}") temp+=name[i] #Count the caracter in string and show to user

Ch 31 infinity loop

 #there is two type of infinity can run #by mistake #by yourself #+=====bye mistake i=0  while i<=10: print("hello world") #by mistake if u sont increse the value of i it can run infinity   # by yourself while True:   print("hello world")

Ch 30 some impo remember

name=input("enter your name") temp_var=" " i=0 while i<len (name): if name[i] not in temp_var: temp_var+=name[i] print(f"{name[i]} : {name.count(name[i])}") i+=1 #Need Help to expert to understand this! In temp Temp_var+=name[i]

Ch 29 practice solution

 number=input("enter the number") total=0 i=0 while i<len(number): total+=int(number[i]) i+=1 print(total) ##I not complete the  program I got help to video

Ch 28 exercise input user

 n=input("enter a number") n=int(n) total=0 i = 1 while i<=n: total+=i i+=1 print(total) #sum of a natural number #ask user for natural number #print total from 1+n

Ch 27 sum number with while loop

 total = 0 i=1 while i<=10: total=total+i i=i+1 print(total) # I mistake print("total") I not put the "" because the print value is int not string i=0 while i<=45: print(i) i=i+1 #the i is impo to increase the value repeat #If you use the while u must assign the variable first and increase the variable values at the last #you also use () to the conditions

Ch 26 while loop

 i=1  while i<=10: print(f"hello world   {i}") i=i+1 #I forgot the put the last line #we use while loop to execute the program many time what ammount u want #if u want unlimited not include the last line.#if u want in amount of print u mast include the last line

C ch 2 printf("")

 Printf() is not a keyword  Printf() is a pre defined function  #.             TWO TYPE OF MASSANGE PRINTING text as it is. Print ("hello world") Printing text as a variable support Main() #this command main o make a to run if this is not present the program not run { #curly braket is make to the code body Getch(); # this comment can help to stop your display stop if u enter any keyword on it the main display will show Display your program and it's a output intraction!! } Like this -:::: Main() { Printf("hello world"); -------- the ; command is impo to end the program Getch(); }

C ch 1 what is c language

C is a pronounced "c-sharp". It is a object -oriented programming language create by Microsoft that runs on the .net framework C# has roots for the cfamily and the language is close to other popular language like c++ and java. The first version was released in year 2002 the letest version c#8 was released in September 2019 C# is used for  #1 mobile app #2 desktop app #3 web app #4 web service #5 web sites #6 games #7 vr #8 database app #and mach more           WHY WE USE C#  #1 it is the most of the popular language in the world #2 it is easy to use to learn and simple to code #3 it has a object oriented language which gives a clear structure to program and allows code to be reused dowering development costs. #5 as c# is close to c/c++ and java is u learn it the main consept is clear in all program  What is computer? Computer is a election device that takes input , process and it gives output.             DIFFERENCE B...

C language start

 Start the c language 

Ch 25check empty or not

 name=input("enter your name") if name: print(f"your name is\t{name}") else: print("you dont type anything try again") # it is simple code to check the user type anything or not !! 

Ch 24 in keyword

 name="ankit" if 'a' in "name": print("present") else: print("not present") #In this code we can find the a character in the string are present or not this not work with input I try!!

Ch 23 if elif else statement

 age=input("enter your age please") age=int(age)     if age==0:   print("you canr watch the movie") if 0<age<=3: print("ticker price 100") elif 3<age<=10: print("ticker price 200") elif 10<age<=60: print("ticker price 300") else: print("you cant watch the movie") I mistaken in this code i always blank the line in starting on if and elif or else the space is cause the error in the code beware to the blank and space remember that always!

Ch 21 or the coco movie age limit

 input_name=input("enter your name")  input_age=input("enter your age") input_age=int(input_age) if input_age >= 10 and (input_name[0] =='a' or input_name[0]=='A'): print("you watch") else: print("you can not") I mistaken many time in the indexing the name [0] 'a' beware to the indexing the name you can indexing the name and anything by ch(13 ) len function !!

Ch 22 and or oprator

 # Use for check two or more condition  name = "ankit" age =19 if name=="ankit" and  age == 19: print("true") else: print("false") #This function can use to check all the condition  # in or statement if condition is true overall the all condition are true automatically

Ch 21 the winning number game

winning_number=27 user_input=input("enter your gusse number") user_input=int(user_input) if user_input==winning_number: print("you win") else: if user_input < winning_number: print("too low") else: print("too high") # i mistaken many time on the if user_input<winning_number line beware of the : sigh it is impo

Ch 20 else statement

 #The else command run if user under the age #If user input 15 and more the if statement will work in the function age=input("enter your age") age=int(age) if age>14: print("you can play this game") else: print("you can not play this game")

Ch 19 if statement

 #if statement use to check user conditions age=input("enter your age") age=int(age) If age >=14: ------the last one is impo           Print("you can watch the movie") #And the space in starting is important

Ch 18 assistant oprator

#this command is used to change variable without touch the first one Like #i can include kumar in it like this #Ther is to type to do that #  1 name = "ankit" name = name + "kuswaha" print(name) #2 name="ankit" name += "kumar" print(name)

Ch 17 string immutable

 Mutable-- mutable variable can change the value string anything  Immutable-- immutable variable can't be change anything

Ch 16 center method

 name="Ankit" x=name.center(100) print(x))  #to center your your code by chage the value  in the braket #You can use nay number in this function name="ankit" x=name.center(20,"2") print(x) #U can set what u want in the "int the box when u type anything toh code can loop the same thing

Ch 15 find and replace method

 string = "she a is beutiful girl" print(string.replace("what you want to replace", "which word replace with first word")) Like+===== String="she is a beautiful girl" Print(string.replace("is","the"))

Ch 14string method

 name=len("ankit") print(name)  #this fuction is used to count the cragter in your string # lower method name="ANKIT" print(name.lower()) #this can lower chracter all your string chose by u  #you can use upper method and tittle method to in this function a =  "Hello, World!" print (a.upper()) #This method change all chrahter into capital a =  "Hello, World!" print (a.replace( "H" ,  "J" )) #("What u want to replace","what u need after replace")

Ch 13 string slicing

 language="python" Print(language [0:5]) # if u want to print all your word you can add 1 of your number Like +=== Language="python" Print(language [0:6]  # this can print all your python word  but you can change replace with 5 this function type only o not n         This only start with 0 1 2 3 4

Ch 12 position counting

 The counting can start with -3 -2 -1 0 1  2 3 language="python" Print (language [5]). # we use this [] to index the number

Ch 11 string formatting

 name="ankit" age = 24 Print("hello"+name+"your age is"+(str(age)) # ugly syntax in this way your code is look very missy But u want to use this syntax to show your code look nice name ="ankit" age = 12 print(f"hello{name}your age is{age}") # the    f           is impo to use this syntax

Ch 10 two or more input in one line

name,age=input("enter your name and age").split (" ") print("your name is"+name+"your age is"+age")

ch 9 variable more

name,age=input("enter your name"="enter your age") print("your name is "+name+"your age is "+age) #       you can use , to input many more  

ch 8 int()

 number_one=int(input(enter your first number)) number_second=int(input(enter your second number)) print("your first number is/t"+number_one+"your seconf number is/t"+numner _second") #     if you type int in first in  starting the input can print number not string and chracters  

ch 7 user input

 name=input("type your name") print("hello"+name)  #   inpurt command can help to ask your user anything you want likr name age and height age=input("type your age") print("hello your age is"+age) #   input can omly use string formate but you can use int to print number on it

ch 6 string concatenation

 first_name="ankit" last_name="kuswaha" #add the full name full_name=first_name+last_name print(full_name) string can use another string print(full_name+"3") we can use calculator command it can print the name 3 times pritnt(full_name+"*4")

ch 5 variable

 number1=2 print(number1) number2=3 print(number2) variable can't start with the number  variable can start with the letter,_ user_one_name       #     this is snake case writing User One Name       #    this is camel case writing

ch 4python as a calculator

 print (2=3*4) to python as a calculator program commands addition                    + subtraction                                 - multiplaycation                        * float division                           / integar division                     // exponent                               * remander                                %    like+==== print (round(2**0.5,4))  

ch 3 emoji website

  emoji link                               this is emoji link you can use for print emoji and many more

ch 2 escape sequences

escape sequence  |,   single quote |,,   doble quote \\     back slash \n     for line line to print another line not in same line  \t     tab for more space like +=== print("line a \n line b")     this can print line A in one line and line 2 in another line print(r"line a \n  line b ") this can use for print normal text                                  

ch 1

print is used for print anything on display like print("hello i am ankit") you can use "" this and '' formate but you can not use ("')this it is syntax error  string is anything can use two and more chractar its called string like ("ankit") its is string but ("a") it is chractar
 ch 1 =  print("")                ch 2 = escape sequence ch 3 =emoji website icon ch 4 = python as a calculator ch 5 = variable --------------ch 1 end ch 6 =strings concatention   - string are represent with ""   ---------------ch 2 start ch 7 =user input ch 8 = int() ch 9 = variable more ch 10 = two or more input in one line ch 11 = string slicing ch 12 =position counting ch 13 = stringslicing ch 14= string  method ch 15 = find and replace metgod ch 16 = center method ch 17 = string immutable ch 18 = assigimnt oprator ------------------ch 2 end ch 19 = statement ch 20 = else statement ch 21 = nested  if-else , correct number game ch 22 = and or oprator ch 23 = if elif else statement ch 24 = in keyword ch 26 = while loop ch 27 = sum number with whille loop ch 28 = exercise input user ch 29 = practice solution ch 30 = some impo remmeber ch 31 = infinty loop  ch 32 = for...