Overall company coding pratics with full concepts in python language.

RP SINGH
RAVI KUMAR SINGH

                                    DAY :01                                

πŸ”°

# guess the output

data={}

print(type(data))

# eska output disconary aayega.

πŸ”°

#Guess the output of the code.

a=set()

print(a)

# yah empty set ko generate krega.

πŸ”°

#Guess the output of the code.

print(-10//3)# yaha flwer division ho rha hai.

# eska output -4 aayega kyuki jb 3 se divide krenge to -3aur-4 but near me -4 hoga aur near wale ko flower bolte hai aur dur bale ko ceil bolte hai.


print(10//3) # output 3 aayega


print(20//5) # output 4 aayega.

# ye sabhi flower division ke example the .

πŸ”°

# print the below output.

# "python uses \n for new line"

print( ' "python uses \\n for new line" ') # eska output same aayega

πŸ”°

#print the output below

# /\/\/\/\

print('/\\/\\/\\/\\')# yadi 3 back slash cheia to 6 back slash lagana padega.

πŸ”°

# print the below output of the code.

#/\/\/\/\/\/\/\/\/\/\/\

print("/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\")

πŸ”°

print('"///////"') #output: "///////"

πŸ”°

print("\\\\\\\\")

πŸ”°

# what is the output of the below code

name="shantanu"

print(name[2:8:2])# output  atn

πŸ”°

print(name[2:8:-2])# output no any result or output.

πŸ”°


# what is the output of the below code.

my_dict={"jay":89,"viru":81,"jay":51}

print(len(my_dict)) # output of the code is 2.because duplicate key exixt nhi krte hai disconary ke under.

πŸ”°

# meargr the lists

a=[3,4,5]

b=[5,6,7]

c=[1,2,3]

print(list(zip(a,b,c)))


                                 DAY:02                                    

πŸ”°
print(10.0//3)# eska output 3.0 aayega because flower division me yadiek bhi float hota hai to float hi answer aayega.

πŸ”°
# Guess the output of the following python code
num=2E3
print(num)# eska matlab 2*10^3 jeska answer aayega 2000.0
#esme 2 mantasa hai 10 base hai aur 3 exponential hai.
# eska use bhout bade ya bhout chote value k liye krte hai.

πŸ”°
# Guess the output of the following python code
num=2E3
print(type(num)) # Eska answer float aayega

πŸ”°
# Guess the output of the following python code.
for i in 785>1:
    print(i)
    # output is type error because condition hai jabki itrable matlab kha tk chlega wo hona cheia tha jabki opposite hai.

                                                  

                               DAY:03                                      

name="swapanali walke"
name1="Swapanali walke"
print(name==name1)# output false

print(name>=name1) # output true aayega ord number ke adhar pr . 
print(ord('a'))# small a ka ord number is 97
print(ord('z'))# small z ka ord number is 122
print(ord('A'))# capital A ka ord no is 65
print(ord('Z'))# capital Z ka ord no is 90

#note: small wale ka ord no jyde hota hai capital wale se eslea true aa rha tha .

                               DAY:04                                      

Ternory operator in python programming............

age=20;
message="you can vote" if (age>=18) else "you can not give the vote"

print(message)

...........................................................................
C language me es thrah se ternary operator kaam krta hai...........................

// Online C compiler to run C program online
#include<stdio.h>

int main()
{
    int num1=10;
    int num2=20;
    int max;
    /*here ternary operator are use this point */
    max=(num1>num2)?num1:num2;
    printf("%d",max);
    return 0;
}
.............................................................................
2.
// Online C compiler to run C program online
#include<stdio.h>

int main()
{
    int age=20;
    char *message; # *use for multiple string
    message=(age>=18)?"you can give the vote":"you can not give the vote";
    printf("%s",message);
    return 0;
}

                               DAY:05                                      

Q: what is PEP8?

# PEP8 is a python enterprise protocol.

# it means A document that provide guidelines and     best pratices on how to write python code..........

# Esko 2001 me sir Guido ben rossum ne lekha tha 

# Naming convention ko solve krne keliye .

# jb bhi koi module import kre than uska name builtin module nhi hona cheia.

yani yah bateta hai python ke unnder keseacche thrah se coding kre taki koi problem ya name conflict na occure ho.



                               DAY:06                                      

Q:What is walrus operator in programming?
Ans: Walrus operator(:=) is a type of operator jo ki multiple line code ko minimumline me lekh kr de deta hai.
eg:-
a=100
print(a+1)
# Same code with helpof walrous operator
print((a:=100)+1) # Eska bhi output 101 aayega

# pratics on array type questions
data=[10,20,30,40,50,60,70]
n=len(data)
i=0
while(i<n):
    print(data[i])
    i=i+1
    
    
# now using walrous operator
data=[10,20,30,40,50,60,70]
i=-1
while(i:=i+1)<(n:=len(data)):
    print(data[i])
    
    
# next pratices.
ans=input("Do you want to continue(y/n):").lower()
while (ans=='y'):
    
 print("process the request")

# using walrous
while(ans:=input("Do you want to continue(y/n):").lower()=='y'):
    print('process the continue')
    
#Note: Esme jo phle se hai uske asthan pr same type wale ko paste kr de rhe hai aur saath saath warlson operator ka symbol bhi lga de rhe hai.    

                                DAY:07                                     
Q: Differance between list and tuple.
Ans:-
Lists and tuples are both data structures in Python that can store collections of items. However, they have some key differences:

1. **Mutability**:
   - **List**: Lists are mutable, meaning you can modify their contents (add, remove, or change items).yani list ke under ke value ko change kr skte hai.
   - **Tuple**: Tuples are immutable, meaning once a tuple is created, you cannot modify its contents.eske under ki value ko change nhi kr skte hai.

2. **Syntax**:
   - **List**: Lists are defined using square brackets `[ ]`.
     ```python
     my_list = [1, 2, 3]
     ```
   - **Tuple**: Tuples are defined using parentheses `( )`.
     ```python
     my_tuple = (1, 2, 3)
     ```

3. **Performance**:
   - **List**: Lists have a higher overhead due to their mutability and the need to manage dynamic memory allocation. They are generally slower compared to tuples.
   - **Tuple**: Tuples are faster and more memory efficient because they are immutable and have a fixed size.

4. **Use Case**:
   - **List**: Use lists when you need a collection of items that may change throughout the program (e.g., adding/removing elements).
   - **Tuple**: Use tuples when you need a collection of items that should not change (e.g., coordinates, fixed sets of values).

5. **Functions and Methods**:
   - **List**: Lists have various methods available to modify their contents, such as `append()`, `remove()`, `sort()`, etc.
   - **Tuple**: Tuples have fewer methods since they do not support modification. They mostly support methods that do not change the content, such as `count()` and `index()`.

6. **Slicing and Indexing**:
   - Both lists and tuples support slicing and indexing to access elements.

7. **Packing and Unpacking**:
   - Both lists and tuples can be used for packing and unpacking values.

Example of packing and unpacking:
```python
# List packing and unpacking
a, b, c = [1, 2, 3]
my_list = [a, b, c]

# Tuple packing and unpacking
x, y, z = (4, 5, 6)
my_tuple = (x, y, z)
```

In summary:
- Use lists when you need a dynamic, modifiable collection of items.
- Use tuples when you need a fixed, unchangeable collection of items.


Q:Why we use list?why we use tuple? and when?
Ans:- Jb data ya values ko change krna ho to hum list use krte hai kyuki esme changing ho skta hai

Jb data change krne ki jarurat na ho to hum tuple use krte hai kyuki yah bhout km memory letahai as acompare to list.aur esme channging process nhi hai .


                                DAY:08                                     
                                          
Q Some logical questions for placement..........

input:-"sky is blue"
output:-"blue is sky"
Ans:-
str1="sky is blue"
my_list=str1.split()# spliting based on white space.jesce sabhi words space k saath alag ho jyenge.'sky','is','blue'
#now reverse the string
my_list=my_list[::-1]# slicing ka use krke reverse kr rhe hai.
# now join based on white space or space"  " 
str2=" ".join(my_list)
print(str2)

Q2: List=[1,2,2,3,3,4,5,5,5,6,6]
output:-[1,4]
Ans;
list=[1,2,2,3,3,4,5,5,5,6,6]
new_list=[]# ek new empty list baniyenge.
for num in list:
    if list.count(num)==1: # yaha logic use hua hai.
        new_list.append(num)# yadi conditionshi haito hum eske under append kr denge.
print(new_list)        
        




                                DAY:09          

Q: What is python language?
Q:Define python?





                       DAY:10                   

Q:How python works?
step1: Write source code.
step2: compile code using python compilar.
step3: compilar convert into byte code.
step4: computer does not understand bytecode.
step5 Ab python vertual machine esko convert krta hai byte code me using interpretor.

Q: Hume compilar aur interpretor dono ki need kyu padi?
Ans;- πŸ‘‰Compilar fast kaam krta hai but protobality(aasani nhi )deta.

πŸ‘‰Interpretor aasani deta hai pr speed nhi deta .

πŸ‘‰Speed aur aasani(protobality) dono dene ke liye python compilar interpretor ka use krte hai.


                                DAY:11                                     






Comments

Popular posts from this blog

Python Complete notes with code and explanation in hindi english both language.

Find the largest three distinct elements in an array