codepedia
5.88K subscribers
1.39K photos
890 videos
615 files
816 links
💞 هدف این کانال آموزش رایگان برنامه نویسی💥
↩️دوره های موجود رو از دست ندید😍
❌️اینجا‌منبع کتاب های برنامه‌نویسی نامبروانههه🥳
Download Telegram
پیداکردن ارور برنامه به صورت اتوماتیک
در این کد شما میتونید ارورهای موجود در کد خاصی رو به شکل اتوماتیک در استک اورفلو جستجو کنید.
# Import dependencies
from subprocess import Popen, PIPE
import requests
import webbrowser

# We are going to write code to read and run python
# file, and store its output or error.
def execute_return(cmd):
args = cmd.split()
proc = Popen(args, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
return out, err

# This function will make an HTTP request using StackOverflow
# API and the error we get from the 1st function and finally
# returns the JSON file.
def mak_req(error):
resp = requests.get("https://api.stackexchange.com/" +
"/2.2/search?order=desc&tagged=python&sort=activity&intitle={}&site=stackoverflow".format(error))
return resp.json()

# This function takes the JSON from the 2nd function, and
# fetches and stores the URLs of those solutions which are
# marked as "answered" by StackOverflow. And then finally
# open up the tabs containing answers from StackOverflow on
# the browser.
def get_urls(json_dict):
url_list = []
count = 0

for i in json_dict['items']:
if i['is_answered']:
url_list.append(i["link"])
count += 1
if count == 3 or count == len(i):
break

for i in url_list:
webbrowser.open(i)


# Below line will go through the provided python file
# And stores the output and error.
out, err = execute_return("python C:/Users/Saurabh/Desktop/test.py")

# This line is used to store that part of error we are interested in.
error = err.decode("utf-8").strip().split("\r\n")[-1]
print(error)


# A simple if condition, if error is found then execute 2nd and
# 3rd function, otherwise print "No error".
if error:
filter_error = error.split(":")
json1 = mak_req(filter_error[0])
json2 = mak_req(filter_error[1])
json = mak_req(error)
get_urls(json1)
get_urls(json2)
get_urls(json)

else:
print("No error")

#codepedia #python #stackoverflow

@code_pedia
سوال : برنامه ای بنویسید که تشخیص دهد عددی اول است یا نه
روش اول : حل با ایجاد یک flag
‍‍‍
n = input()
isPrime = True
# codepedia
for i in range(2, n):
if (n % i == 0):
isPrime = False
break

if isPrime:
print(f'{n} is Prime')
else:
print(f'{n} is not Prime')


روش دوم : حل در روش پایتونیسم
n = input()
# codepedia
for i in range(2, n):
if(n % i == 0):
print(f'{n} is not Prime')
break
else:
print(f'{n} is Prime')


روش سوم : استفاده از تابع
def isPrime(n):
for i in range(2, n):
if (n % i == 0):
return False
#codepedia
return True
👍244
برای دانلود پروژه های جذاب front end میتونید به گیست های گیت هاب ما در آدرس https://gist.github.com/codepediair مراجعه کنید.

#github
#codepedia
@code_pedia
🤩4👍1
چالش پایتون :برنامه‌ای بنویسید که بدون استفاده از اپراتور ضرب با توان، توان دو عدد دلخواه را محاسبه کند.


@code_pedia
#codepedia
#codechalleng
پاسخ : برای این کار میتوان از دو عدد حلقه و اپراتور جمع استفاده کرد
x = int(input())
y = int(input())
# # x^y
if y == 0:
res = 1
else :
temp = x
for j in range(1,y):

res = 0
for i in range(x):
res += temp

temp = res
print(temp)
👍5
چطور از youtube دانلود کنیم؟

اسکریپتی که در ادامه براتون میزارم به زبان پایتون نوشته شده و به راحتی این کار رو براتون انجام میده.

البته کتابخانه pytube امکانات خیلی شگفت انگیزی داره مثلا فقط میتونید موسیقی رو دانلود کنید یا کیفیت‌های مختلف از یک ویدئو رو داشته باشید.
#code
#codepedia
@code_pedia

from pytube import YouTube
yt = YouTube('http://youtube.com/watch?v=CywxLAL2K7w')
# res = yt.streams.filter(file_extension='mp4')

stream = yt.streams.get_by_itag(137)
stream.download()
# print(res)
27👍1
This media is not supported in your browser
VIEW IN TELEGRAM
#game

تمام کنسول‌های نوستالژی نینتندو در یک قاب.
اصلا حال ادم خوب میشه این کلیپ رو میبینه

با کدپدیا همراه باشید
#codepedia
2👍1🔥1