Python Codes Basic to Advance
2.65K 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
What arithmetic operators cannot be used with strings in Python?
Anonymous Quiz
24%
*
13%
+
25%
-
38%
All of the mentioned
# INHERITANCE IN PYTHON


import requests
class GoogleImageAPI:
"""
A simple class to interact with the Google Image API.
"""

def __init__(self, base_url):
self.base_url = base_url

def search_images(self, query):

endpoint = f"{self.base_url}/googleimg?query={query}"
headers = {"accept": "application/json"}

response = requests.get(endpoint, headers=headers)

if response.status_code == 200:
return response.json()
else:
return {"error": f"Failed to retrieve images. Status code: {response.status_code}"}

class Blackbox(GoogleImageAPI):
def init(self,base_url):
super().__init__(base_url)

def blackbox_response(self,query):
endpoint = f"{self.base_url}/blackbox?query={query}"
response = requests.get(endpoint)
if response.status_code == 200:
return response.json()
else:
return {"error": f"Failed to retrieve images. Status code: {response.status_code}"}

bl=Blackbox(base_url="https://mukesh-api.vercel.app")
print(bl.blackbox_response(query="write simple python flask app"))
print(bl.search_images("boy"))
2👍2
Getter and Setters in Python

import requests

class MukeshAPI:
"""
A simple class to interact with the API.
"""
def __init__(self, base_url="https://mukesh-api.vercel.app",endpoint=""):
self._base_url = base_url
self._endpoint=endpoint
@property
def endpoint(self):
return self._endpoint
@endpoint.setter
def endpoint(self, new_endpoint):
self._endpoint = new_endpoint

def search(self, query):
url = f"{self._base_url}/{self.endpoint}?query={query}"
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)

if response.status_code == 200:
return response.json()["results"]
else:
return {"error": f"Failed to retrieve. Status code: {response.status_code}"}
def search2(self):
url = f"{self._base_url}/{self.endpoint}"
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)

if response.status_code == 200:
return response.json()["results"]
else:
return {"error": f"Failed to retrieve. Status code: {response.status_code}"}
def search3(self,api_key, query):
url = f"{self._base_url}/{self.endpoint}?query={query}"
headers = {"accept": "application/json","Api-Key":api_key}
response = requests.post(url, headers=headers)

if response.status_code == 200:
return response.json()
else:
return {"error": f"Failed to retrieve. Status code: {response.status_code}"}

bl=MukeshAPI(endpoint="bhagwatgita")
print(bl.endpoint)
print(bl.search3(api_key="get from @adventure_robot",query=1))
bl.endpoint="truth"
print(bl.endpoint)
print(bl.search2())
bl.endpoint = "chatgpt"
print(bl.endpoint)
print(bl.search("write basic website code using html and css"))
1
Forwarded from ˹ᴍʀ sᴜᴋᴋᴜɴ˼ (Mᴜᴋᴇsʜ)
🫡3
# Foundations of Hacking and Pentesting Android Apps

Run code to download video in ur system

source code : https://github.com/Noob-mukesh/Python-Projects/blob/main/hackingudemycourse.py

About this course
Learn how to hack Android apps, and find vulnerabilties
By the numbers
Skill level: Beginner Level
Students: 55064
Languages: English
Captions: Yes
Lectures: 15
Video: 1.5 total hours
Features
Available on iOS and Android

What you’ll learn
Setting up Android Studio and Emulators
Basics of adb
Decompiling apks
Insecure Logging
Hardcoding Issues
Insecure Data Storage
Input Valdiation Issues
Drozer
Finding Attack Surfaces
Access Control Issues
Content Provider Injections
General Bug Hunting Tips
Are there any course requirements or prerequisites?
A basic understanding of programming

Who this course is for:
Android developers looking to secure their applications
Hackers looking to learn common Android vulnerabilities
🔥21👍1
Guess the Output

Join :- @Python_Codes_Pro

Support group :- @python_group_pro
1
Simple website using python #flask

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
return '@Legend_coder'

if __name__ == "__main__":
app.run()


Join :- @Python_Codes_Pro

Support group :- @python_group_pro
Python Tip for the day:
Use the "enumerate" function to iterate over a sequence and get the index of each element.

Sometimes when you're iterating over a list or other sequence in Python, you need to keep track of the index of the current element. One way to do this is to use a counter variable and increment it on each iteration, but this can be tedious and error-prone.

A better way to get the index of each element is to use the built-in "enumerate" function. The "enumerate" function takes an iterable (such as a list or tuple) as its argument and returns a sequence of (index, value) tuples, where "index" is the index of the current element and "value" is the value of the current element. Here's an example:
#Iterate over a list of strings and print each string with its i
strings = ['apple', 'banana', 'cherry', 'date']
for i, s in enumerate(strings):
print(f"{i}: {s}")

In this example, we use the "enumerate" function to iterate over a list of strings. On each iteration, the "enumerate" function returns a tuple containing the index of the current string and the string itself. We use tuple unpacking to assign these values to the variables "i" and "s", and then print out the index and string on a separate line.

The output of this code would be:
 apple
1: banana
2: cherry
3: date

Using the "enumerate" function can make your code more concise and easier to read, especially when you need to keep track of the index of each element in a sequence.
Number Guessing Game Using python..
import random
def play_guessing_game():
print("Welcome to the Guessing Game!")
# by @mr_sukkun
# join : https://t.me/Python_Codes_Pro
secret_number = random.randint(1, 100)
attempts = 0
while True:
guess = int(input("Enter your guess (between 1 and 100): "))
attempts += 1
if guess < secret_number:
print("Too low! Try again.")
elif guess > secret_number:
print("Too high! Try again.")
else:
print(f"Congratulations! You've guessed the secret number {secret_number} in {attempts} attempts!")
break
play_guessing_game()

Join :- @Python_Codes_Pro

Support group :- @python_group_pro
👍31
Which of the following concepts is not a part of Python?
Anonymous Quiz
50%
Pointers
13%
Loops
27%
Dynamic typing
10%
All of the above
# Pastebin Using Python
import requests
def pastebin(content):
"""
Function to post content to a pastebin service and return the URL of the paste.

Args:
content (str): The content to be pasted

Returns:
str: The URL of the paste
"""
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0"}

data = {"snippet":content}

response = requests.post(f'https://bin.kv2.dev/', json=data, headers=headers)
yield response.url

print(next(pastebin("hi")))

Join :- @Python_Codes_Pro

Support group :- @python_group_pro
2
#python

print(~2) Output will be?
Anonymous Quiz
26%
-2
12%
-3
18%
2
44%
Error
What will be the output of the following Python code?
Anonymous Quiz
32%
a b c
19%
1 2 3
31%
0 a 1 b 2 c
18%
none
Python program that Create a function that gives True if a string is empty and False otherwise.
# - Try it for '' and ' 5gh'
def checkstring(string):
if len(string)==0:
return True
else:
return False
print(checkstring("5gh"))
print(checkstring(""))
#Taskforyou

Write a Python program that remove the extra spaces from the following string:

' I am learning Python object oriented programming '
1👍1
Join :- @Python_Codes_Pro

Support group :- @python_group_pro
🤣4😁1