Python Codes Basic to Advance
2.66K subscribers
82 photos
5 videos
8 files
100 links
Python Codes Basic to Advance

All Codes
@C_Codes_pro
@CPP_Codes_pro
@Java_Codes_Pro
@nodejs_codes_pro

Discussion
@bca_mca_btech
Download Telegram
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Which module in the python standard library parses options received from the command line?
Anonymous Quiz
22%
getopt
25%
getarg
33%
main
20%
os
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Is Python case sensitive when dealing with identifiers?
Anonymous Quiz
23%
No
65%
Yes
12%
Machine Dependent
👍2
def getPrint(name="world", some):
print(f"Hello {name}")
getPrint("Chiku", 55)
Anonymous Quiz
38%
Hello World
35%
Hello Chiku
9%
Hello 55
18%
Error
2
Flask app that interacts with the Waifu API to fetch and display tags and search for images based on parameters you provided. 🚀

### Flask App Structure
1. Install Flask: Make sure you have Flask installed. You can do this via pip:

   pip install Flask


2. Create your Flask app: Below is the complete code for the Flask app:

from flask import Flask, jsonify, render_template
import requests

app = Flask(__name__)

@app.route('/')
def home():
return render_template('index.html')

@app.route('/tags')
def get_tags():
url = 'https://api.waifu.im/tags'
response = requests.get(url)

if response.status_code == 200:
data = response.json()
return jsonify(data)
else:
return jsonify({'error': 'Request failed with status code:', 'status': response.status_code}), response.status_code

@app.route('/search/<tag>')
def search_images(tag):
url = 'https://api.waifu.im/search'
params = {
'included_tags': [tag],
}

response = requests.get(url, params=params)

if response.status_code == 200:
data = response.json()
return jsonify(data)
else:
return jsonify({'error': 'Request failed with status code:', 'status': response.status_code}), response.status_code

if __name__ == '__main__':
app.run(debug=True)


3. Create Template File:
Create a folder named templates in the same directory as your Flask app and create a file named index.html.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Waifu App</title>
</head>
<body>
<h1>Welcome to the Waifu App! 🌟</h1>
<h2>Available Tags and Image Search</h2>
<p>Use the following endpoints:</p>
<ul>
<li><a href="/tags">Get Tags</a></li>
<li>Search Images: <a href="/search/maid">Maid Images</a></li>
</ul>
</body>
</html>


How to Run the App

1. Save the Python script (e.g., app.py) and the HTML file.
2. Run the Flask app:

   python app.py

3. Open your web browser and go to http://127.0.0.1:5000/ to see the app in action! 🎉
5👍4
Jinke pass bhi Groups hain 10 members se 250 members tak ke vo mujhe de sakte hain

(Only telegram groups no newly created)
And don't comment here directly message me

Minimum Price 50 rupye maximum price can be 100 vary based on group

And in special group case it will be more

@Panditsiddharth
Or Call 6389680622
👍3
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you filter rows in a DataFrame based on a condition?
Anonymous Quiz
26%
df.filter(condition)
25%
df[condition]
22%
df.select_rows(condition)
27%
df.filter_rows(condition)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you merge two DataFrames in Pandas?
Anonymous Quiz
25%
df.concat()
20%
df.join()
46%
df.merge()
9%
df.combine()
👍31
We have started new Channel.
Is channels me aapko 8000 se lekar 1lack+ salary ke jobs achive karne ke liye kya skills required hoti hain unke bare me batayenge.

Kya kya jaroori hota hai cv, experience, education and knowledge se lekar bahut kuchh

Har ek field jaise accounting, Software development se lekar Har tarah ke work ki skills.

To wait karne ki bajay join karlo👇

@NaukriSkills
1
Hollow Rectangle Pattern in python
def hollow_rectangle_pattern(Totalrow,TotalCol):
for i in range(1, Totalrow+1):
for j in range(1,TotalCol+1):
if (i==1 or j==1 or i==Totalrow or j==TotalCol):
print("*",end="")
else:
print(" ",end="")
print("")
hollow_rectangle_pattern(4,7)


Output:
*******
* *
* *
*******
👍2
Inverted Half Rotated Pyramid
def inverted_half_pyramid(n):
for i in range(0, n+1):
for j in range(0, n-i):
print(" ",end="")
for j in range(0, i):
print("*",end="")
print()

inverted_half_pyramid(6)

Output:
     *
**
***
****
*****
******
1
Inverted rotated Pyramid of number
def invert_half_pyra(n: int):
for i in range(0, n):
for j in range(1, n - i + 1):
print(j, end="")
print()

invert_half_pyra(n=5)

Output;
12345
1234
123
12
1
1👏1
Floyd`s Triangle Pattern.
def floyd_triangle(n):
count=1
for i in range(0, n+1):
for j in range(0, i):
print(count,end=" ")
count+=1
print()
floyd_triangle(5)

OutPut:
1 
2 3
4 5 6
7 8 9 10
11 12 13 14 15
2
0-1 Triangle Pattern
def zero_one_triangle(num):
"""
Purpose: for triangle pattern
"""
for i in range(1,num+1):
for j in range(1,i+1):
# print(i+j)
if ((i+j)%2)==0:
print("1",end=" ")
else:
print("0",end=" ")
print()
zero_one_triangle(5)

Output:
1 
0 1
1 0 1
0 1 0 1
1 0 1 0 1
3
Reverse an array
import numpy as np
def Reversed(numbers:np.array):
# Reverse an array

start = 0
last = len(numbers)-1
while (start < last):
temp = numbers[last]
numbers[last] = numbers[start]
numbers[start] = temp
start+=1
last-=1



numbers=np.array([2,4,6,8,10,12,14,16])

Reversed(numbers)
for item in range(0,len(numbers)):
print(numbers[item],end=" ")


# time complexbilty: 0(n)
# space complexbilty: 0(1)

Output:
 16 14 12 10 8 6 4 2
7