Posts

Showing posts from June, 2024
Image
 DAY 29(CODE INFINITY) As everyone is having their summer breaks now so I have decided we should also take a summer break of 5 to 10 days and then continue from where we left so till then enjoy and keep exploring  
Image
DAY 28(CODE INFINITY) In this world full  of competitiveness we all want to succeed but sometimes you put your all and didn't make then wait for your time someday you will get it maybe this was not your time so start focus on your work on yourself so Let's get started with this and practice break and continue today... Code for this is : for i in range(1,101,1):     print(i ,end=" ")     if(i==50):         break     else:         print("Mississippi") print("Thank you") Screenshot of repel : Link of the repel: https://replit.com/@shwetaantil97/19-Day-19-break-and-continue#main.py
Image
DAY 27(CODE INFINITY) Today here is another question which is based on f string which we have done in previous blogs so Let's get started .. Question: Write a program to insert  your name and age in the string. Here is answer for this you can take help from this... name = 'Tushar'   age = 23   print(f" Hello, My name is {name} and I'm {age} years old.")  Screenshot for repel which shows how it give output: Link of the repel: https://replit.com/@shwetaantil97/insert-name-and-age-in-string
Image
DAY 26(CODE INFINITY)  Here is a question for you' all today ....... Question : Write a program to greet all person names stored in a list L1 and which starts with 's'  L1 =["Harry", "sohan", "sachin", "rahul"] you should try it yourself as some find it very easy and some okay okay so just give it a try everyone . answer for this is given below you take help from that also code for this question is: l1 = ["Harry", "sohan", "sachin" ,"rahul"] for name in l1:   if name.startswith("s"):     print("hello",name) Screenshot of the repel: Link of the repel: https://replit.com/@shwetaantil97/greet-everyone-name-starting-with-s
Image
DAY 25(CODE INFINITY) Hii everyone a new day in our life with this beautiful day Let's start a new topic string formatting as the topic name suggests we have to format the string and this can be done using two method : 1. format method 2. f-strings f-string can be formatted in much same as str.format() means format method syntax is simple for both methods so Let's get started... Format method : details = "I am {} from{}" name = "Shweta" state = "Haryana" print(details.format(name,state)) f-strings details = "I am {} from{}" name = "Shweta" state = "Haryana" print(f"I am {name} from {state}") if we want to print the value of the variable in the string then you can use the double curly brackets let me show you how to write this  details = "I am {} from{}" name = "Shweta" state = "Haryana" print(f"I am {{name}} from {{state}}") Screenshot of the repel showing outputs of th...
Image
  DAY 24(CODE INFINITY) Hey everyone, Today let's see who is pass or fail in exams so for this we write a code in which we provide the passing marks and also it takes input from you and calculate total and compare if it is greater than passing marks or not so Let's get started... a= int(input("Enter marks of subject: ")) b=int(input("Enter marks of subject: ")) c=int(input("Enter marks of subject: ")) d=a+b+c e=d/300 f=e*100 if(a>=33 and b>=33 and c>=33 and f>=40):   print("you are pass") else:   print("better luck next time") Screenshot of the repel: Link of the repel: https://replit.com/@shwetaantil97/pass-or-fail#main.py
Image
 DAY 23(CODE INFINITY) As we have seen a star pattern yesterday we also practice some more patterns today when I  started writing code for the pattern. I was not confident at that time but when output came I feel like I can do anything dude and frankly telling when I don't know something, I start writing no matter it is right or wrong I just write it and press enter key whatever I get , I made changes according to my need so in my thought starting is important you'll also heard first step is always the hardest with this Let's get started ... First Pattern: name='*' for i in name:       print(i,end=" ") print('\n') name1='**' for i in name1:       print(i,end="  ") print('\n') name2='***' for i in name2:       print(i,end="  ")       print()   Second pattern: for i in name:       print(i,end=" ") print('\n') name1=' ***' for i in name1:       print(i,end="  ") print(...
Image
  DAY 22(CODE INFINITY) Today we will see some codes to print some pattern using loops so Let's get started with a simple pattern and that is: * * * * * * we will print this using a code: name='*' for i in name:       print(i,end=" ") print('\n') name1='**' for i in name1:       print(i,end="  ") print('\n') name2='***' for i in name2:       print(i,end="  ") Screenshot of the repel: Link of the repel: https://replit.com/@shwetaantil97/star-patterns#program%20to%20print%20star%20pattern%201,2,3%20star%20pattern.py
Image
 DAY 21(CODE INFINITY) Hey everyone, Today I am giving you all a Quick Quiz and you all can give your answers to me if you want I am also giving the link of the repel which have the solution and screenshot you can also take help from that so Let's get started... Quick Quiz : Write a program to print yes when the age entered by the user is greater than or equal to 18. I know some find it quite easy but I just want you all to try that's why I have given easy one with time we will increase the level and you all can give the link of repel or any other interpreter you are using in the comment section.  All the best... Screenshot of the repel : Link of the repel: https://replit.com/@shwetaantil97/Quick-Quiz Use them if needed.
Image
  DAY 20(CODE INFINITY) Today we are gonna discussing the code if you are selected or not .It's quite interesting na that this will decide your selection but it   is only  a database where data already entered and it just provide whether you are in list or not same like result already made and on result date you just need to enter your name and check whether you made it or not so Let's get started... name=input("Enter your name : ") if name in ("shweta","Mohit","Anjali","Rishika","shreya","akshita","surbhi","annu","Nividita", "Meemansha"):   print(name, "you are selected") else:   print("you are not selected. It's ok try another time") Screenshot of the repel:   Link of the repel: https://replit.com/@shwetaantil97/you-got-selection-or-not#main.py
Image
  DAY 19(CODE INFINITY) Today as I said we will provide a code which will give you grade by taking marks input of all the subjects and evaluate your total marks percentage and will give grades on basis of it so Let's get started ... subject1=int(input("Enter marks of subject 1: ")) subject2=int(input("Enter marks of subject 2: ")) subject3=int(input("Enter marks of subject 3: ")) subject4=int(input("Enter marks of subject 4: ")) subject5=int(input("Enter marks of subject 5: ")) total= subject1+subject2+subject3+subject4+subject5 average=total/5 print("Total marks: ",total) percentage=(total/500)*100 print("Percentage: ",percentage) if (percentage>=90 and percentage<=100):   print("Grade = Execelent") elif (percentage>=80 and percentage<=90):   print("Grade = A") elif (percentage>=70 and percentage<=80):   print("Grade = B") elif (percentage>=60 and percentage<...
Image
DAY 18(CODE INFINITY) As I said  we write code for some daily basis things so Today I am giving you a code where you can provide your marks and it will give you grade according to marks in a test of maximum marks(100) also we will write code for all subjects and then according to percentage it will provide grades this we will write in next blog  so Let's get started... #Grade in test of Maximum marks 100 totalmarks=int(input("Enter your marks: ")) if (totalmarks>=90 and totalmarks<=100):   print("Grade = Excellent") elif (totalmarks>=80 and totalmarks<=90):   print("Grade = A") elif (totalmarks>=70 and totalmarks<=80):   print("Grade = B") elif (totalmarks>=60 and totalmarks<=70):   print("Grade = C") elif (totalmarks>=50 and totalmarks<=60):   print("Grade = D") else:   print("Grade = F") Screenshot of repel: Link of repel: https://replit.com/@shwetaantil97/grades-according-to-marks
Image
 DAY 17(CODE INFINITY) Today we continue our previous topic tuples in this we study today operations in tuples as we all know tuples are immutable , if you want to add, remove or change tuple items, then first you must convert the tuple to a list. Then perform operation on that list and convert it back to tuple. We convert the tuples to a list, manipulate items of the list using list methods, then convert list back to a tuple and we can directly concatenate two tuples without converting them to list. Tuple Methods: 1. count(): This method returns the number of times the given element appears in the tuple. 2. index(): This returns the first occurrence of the given element from the tuple  Let me give you an example of how this works: tup=("Shweta","Anjali","Mohit","papa","mummy","sadness") abc=tup.count("Shweta") print(abc) abc=tup.index("Mohit") print(abc) abc=tup.remove("all") print(abc) Screensho...
Image
DAY 16 (CODE INFINITY) Today's topic is tuples, they are collection  of data items and they store multiples items in single variable . Tuples are separated by commas and enclosed with round brackets (). They are unchangeable means we cannot alter them after creation. Tuple indexes: Each item or element has its own unique index same as we done in lists, range ,positive ,negative indexing is also same as we done in lists. Let's write code for this which make things clear in mind. tup=(1,2,3,4,5,6,7,8,9,10) print("the type of tup is",type(tup)) print(tup) print(tup[0]) print(tup[1]) print(tup[2]) print(tup[3]) print(tup[4]) print(tup[-6]) print(tup[-5]) if 10 in tup:   print("yes 10 is present in tup") print(tup[5:9]) print(tup[:]) print(tup[-8:-2]) print(tup[-8:-2:2]) Screenshot which shows how it goes: Link of the repel: https://replit.com/@shwetaantil97/-Introduction-to-Tuples
Image
 DAY 15(CODE INFINITY) Good evening, Like I am greeting you all after seeing time in my clock computer can also do so if you give him right commands in his language .We have clock , for providing clock to computer we have to import time so Let's get started... # Greet people according to time import time  timestamp=time.strftime('%H:%M:%S') print(timestamp) timestamp=int(time.strftime('%H')) if (0<timestamp<12):   print("Good Morning") elif(12<timestamp<17):   print("Good Afternoon ") elif(17<timestamp<20):   print("Good Evening") else:   print("Good Night") Screenshot of the repel : Link of repel: https://replit.com/@shwetaantil97/time#main.py   
Image
DAY 14(CODE INFINITY)  There is a small topic which comes after conditional expression which we skipped. Today we study  match case which is addition to python language to make is easier. It is more or lase same as if else . Code which shows how match case gives output: x=int(input("Enter a number: ")) match x:   case 0:     print("x is zero")   case 1:     print("x is one")   case n:     print("x is not one or zero") Screenshot of the repel: Link of the repel : https://replit.com/@shwetaantil97/match-case#main.py
Image
 DAY 13(CODE INFINITY) Today we study about list methods as we have discussed about lists in previous blog so I hope lists are very clear in mind that they are changeable so we apply different methods according to our need. we se uses of every method here I give you brief about every method in easy language. There are following list methods: 1. Sort : This method sort the list in ascending order original list is updated. you can call this as sort subtype if you need list in descending order for this you can use reverse=True.  2. reverse: This will reverse the order of the given list. 3. index : This method returns the index of first occurrence of the list item. 4 .count : This returns count of number of items with the given value. 5. copy : This returns copy of the list. This can be done to perform operations on the list without modifying the original list. 6. append: This method appends items to the end of existing list. 7. insert : This inserts an item at the given index....
Image
  DAY 12(CODE INFINITY) Today we start new topic lists. Let me give you a brief introduction to lists.  * Lists are ordered collection of data items. *They store multiple items in a single variable. *List items are separated by commas and enclosed within square brackets[]. *Lists are changeable meaning we can alter them after creation. List index : Each item/element in a list has its own unique index. This index can be used to access any item from the list. The first item has index [0], this is same like we done in string slicing just like that we do negative indexing also my short trick for negative indexing is add len(variable) before the negative index given and the positive  index appear then do same like we do in positive indexing. You can also check whether an item is present in the list using conditional expression let me show you an example: colors = ["Red", "Green", "Blue", "Yellow", "Green"] if "Orange" in colors:   ...
Image
                                                       DAY 11 (CODE INFINITY) Today we  continue our functions topic in which we start function arguments .There are four types of arguments that we provide in functions: 1. Default Arguments : In this we can  provide a default value while creating the function by this function assumes a default value even if a value is not provided in the function call for that argument. 2. Keyword Arguments : We can provide arguments with key= value , this way interpreter recognizes the arguments by the parameter name. 3. Variable Length Arguments : We may need to pass more arguments than those defined in function for that we use this argument which have two types:  (a)Arbitrary Arguments: A * before parameter name while defining the function this way function accesses the arguments by processing them...
Image
  DAY 10 (CODE INFINITY) Hey everyone!! Hope you are enjoying it there are many more interesting topics in it  as everybody says python is amazing language it has simple syntax much like English language , you guys know I am pretty much confused about which thing to learn first DSA or Web development or App development but main thing is start with anything with the time you will learn everything  with this thought let's start our Today's topic Functions interesting topic simply we can make anything function for which you write a code of let say 10 lines or 20 lines even if it is of 2 lines but you have to use it multiple times in your programme so simply you can define it as a function in starting and use it anywhere in the code. Functions are of two types: 1. Built-in function (pre defined in python) : some examples- min(), max(), len(), sum(), type(), range(), dict(), list(), tuple(), set(), print() etc.  2. User defined (which user can define) built-in are pre cod...
Image
 DAY 9(CODE INFINITY) Let's do something interesting Today I know I am little boring these days reason for this is I only talk about the topic , give you the code and output of it . This makes blog boring or maybe some non - tech readers may find this non interesting so I thought about it and find a solution that after every two days we do interesting activities like we make programs on some daily use things .....so our Today's activity is to make calculator in python you can also try yourself or can take help with the code which is given below: #create calculator x=int(input("Enter value of x: ")) y=int(input("Enter value of y: ")) print("The value of" ,x, "+",y, "is" ,x+y) print("The value of" ,x, "-" ,y, "is" ,x-y) print("The value of" ,x, "*" ,y, "is" ,x*y) print("The value of" ,x, "/",y, "is" ,x/y) print("The value of" ,x, ...
Image
 DAY 8(CODE INFINITY) Today's we continue our same topic of conditional expressions . We use if else with both for loops , while loops and other statements like break statement, continue statement ,pass statement etc. Let's get started..... name='Shweta' for i in name: print(i) if (i=='w'):     break else:       print("Done with the loop") Another example with while loop: n=0 while i in (n>0): print(i) i=i+1 break statement : This statement instructs the program to exit the loop. continue statement: This statement instructs the program to 'skip the iteration' . pass statement: This is a null statement it instructs to 'Do nothing' . Screenshot of the repel given below: Link of the repel: https://replit.com/@shwetaantil97/conditional-expressions-with-loops#main.py  
Image
DAY 7(CODE INFINITY)  Today we talk about a topic named conditional expressions in which  we  mainly  have three keywords  if , else , elif. Let's use all of them in a code.... x=int(input("Enter value of x: ")) y=int(input("Enter value of y: ")) if (x>y):         print("x is greater than y") elif (x==y):         print("x is equal to y") else:         print("x is less than y") This is a simple code which demonstrate the use of if , elif and else . You will get more clarity when you see its output so move to the screenshot of the repel which shows how it run. Shows output of all three cases Link of the repel : https://replit.com/@shwetaantil97/Day-7conditional-expressions   
Image
  DAY  6(CODE INFINITY) Before starting  I would like  to tell you'll that you  can give your reviews about this in the comment section and if you like reading my blogs you can follow me , this will notify you about my blog . Today's topic is while loop as we have discussed for loop earlier like for loop it also has very simple syntax : i=0 while i in range(5): print(i) i=i+1 This is  simple example of while loop we can also use while loop with conditional expressions like if , else, elif etc.  which we cover in coming blogs. We can also print table of 5 using while loop  code of this also given below in the screenshot.    Screenshot of repel which shows how the above code gives output: Use of while loop If you find this screenshot blur double tap on it , it will open in another window. Link of repel: https://replit.com/@shwetaantil97/While-Loops-1  
Image
  DAY 5 (CODE INFINITY) Let's move forward in this marathon with another interesting topic  loops. They can iterate over a sequence of iterable objects in python  There are two types of loops : 1. For loop 2. while loop we will discuss for loop first then while loop in coming blogs so  Let's get started...…. Also done in previous blog. name="Shweta" for characters in name: print(characters) We can print table of five using  for loops and while loop as  syntax is very easy and convenient in loops . for i in range(5,51,5) print(i) Screenshot of about two codes : Link of repel: https://replit.com/@shwetaantil97/Python