Click here to Skip to main content
15,891,777 members
Everything / Programming Languages / Python

Python

Python

Great Reads

by Thomas Weller
Demonstrates how to run Python scripts from C#
by Clark Fieseln
Protect your privacy against malicious network activity and policy violations
by Akhil Mittal
Creating a real-time chatbot using Amazon Lex Services and deploying the bot over Facebook messenger
by Marc Clifton
My adventure with hardware and communicating between a BeagleBoneBlack and a C# app on Windows.

Latest Articles

by Azim Zahir
This article is a demonstration of some of the capabilities of the OpenCV library of Python.
by Oliver Li 2024
Java Code Change Impact Analysis
by Chris Maunder
Learn how to process a video file offline using CodeProject.AI Server
by Matthew Dennis
Create a ChatGPT-like AI module for CodeProject.AI Server that handles a long-running process.

All Articles

Sort by Updated

Python 

5 Sep 2022 by #ODSDOMS
The class has the following methods: - A constructor with one tuple argument called coefficients to define and initialize two instant variables, a and b, with default values of 0. - getCoff method that returns a tuple of...
29 Dec 2010 by #realJSOP
If you google "consume web service with python", you'll get *more* than 10 MILLION results...
16 Jan 2011 by #realJSOP
I think the only way you could pull this off is if the application in question could be constrained in a window that your own application creates. Since X-Plane is a game, and since most game companies would never even consider running their game in a window that wasn't borderless and full...
9 Sep 2011 by #realJSOP
Google reveals all.A skinned dialog in Python and MFC[^]
27 Dec 2011 by #realJSOP
17 MILLION google results for the search phrase "learn Python"[^]...and the first two results returned are beginner articles. Goggle reveals all.
27 Dec 2011 by #realJSOP
This makes generic TWO Python questions from you in the last ten minutes.None of us are fortune tellers. Most of us here use C# rather than python, because this is primarily a Microsoft technology oriented development site. Pick one or the other (or both), and get on with your life (and let...
15 Sep 2018 by #realJSOP
If it's a sql server database, create a SSIS package to to it. That's the absolute easiest way to do it.
10 Jan 2019 by #realJSOP
I suggest comment out as much as possible and compile to make sure a codeless app copiles correctly, and then start adding code back a little at a time, and compile after each part is added back. Do this until the copile fails, and you've at least narrowed down your problem and can concentrate...
28 Mar 2019 by #realJSOP
Try this (no guarantees, just a stab in the dark): if (data.lower() == "exit"): or maybe if (data.lower().startswith("exit")):
17 Jul 2022 by & sreenu 2022
Given input : HELLO I AM KARTHIK Output be like : KIHTR A KM AIOLLEH NOT BE LIKE :KIHTRAK MA I OLLEH What I have tried: First word length IS EQUAL to output first word length
N 25 Apr 2024 by 01fe20bec297
I have a frame which consist of many tablets. There are spots on the tablets. I want to detect those spots which are on tablet. The spots are of random color, random shape and random size. How can i detect these spots using image processing? ...
7 Jul 2014 by 09hadi
Hello everyone, I recently started working with Python django (a compulsion by my company). I have been trying to get it working but it keeps on giving me errors. Can anyone please help me with this? I am getting "ImportError at / No module named 'models'"I am following this...
2 Jan 2022 by 0x01AA
Provided, your example data ['2017-01' '2017-01' '2017-01' ... '2021-03' '2021-10' '2021-12'] is an array (and you simply forgot the commas) the following would extract the months for a give year dates = ['2017-01', '2017-01', '2017-01',...
2 Jan 2022 by 0x01AA
What OG means is (I think at least) better use something like this: def file(): while True: file= input("Enter file name(test.txt): ") try: if file == "": break with open(file) as f: with open("another.txt", "w") as...
3 Jan 2022 by 0x01AA
To print only the days without hh:mm:ss you can use this: print(difference.days,"days")
21 May 2022 by 0x01AA
Your approach, doing it from scratch is pretty ok to learn/train programming. In praxis it is usually better to use the tools the language already supports. This because they are tested and you can rely on them. Therefore I suggest to have a...
17 Jul 2022 by 0x01AA
See also the comments to the question. The problem is, that you evaluate with the variables player and computer (which hold the strings'Paper', 'Stone', 'Sissor') instead of no and pla.
1 Jan 2023 by 0x01AA
While I have no expirience in Python, a short google lead me to this: from math import sqrt # loading decimal library from decimal import * def main(): n = '2.0' a = Decimal(2) root2th = sqrt(float(n)) print(root2th) ...
20 Feb 2023 by 0x01AA
Solved by OP. Please see also comments to the question.
14 Mar 2024 by 0x01AA
You did not explain what you excpect and what you get. Anyway... 1. What is the aim of continue_flag? I don't see a reason for that. Remove it. 2. Sum of 1 up to xyz: Ok starting with zero is not critical because adding 0 does not change...
27 Jan 2020 by 10xlearner
How to format CMake files
16 Jul 2015 by 123420
Try int; { { { label.access = accessLimit.Int;intVal{useExcrimintories:viewPort_1} acrossVal.usbPortviewPort() ; internalUseP[internalAdd{[label.y==MessageIgnore],onOperation(display=)]} random(); accessPort=true binary ;;portReadOnly=true...
27 Aug 2020 by 1NilusNIlus
Describe the problemI'm having trouble with my python platformer collision logic, i've recently started following tutorials of a youtube creator for pygame platformers. And had no trouble in making a platformer until the collision logic. I tried...
7 Sep 2023 by 2011999
I am trying the below code. I got this error: Python 3.11.4 What I have tried: from selenium import webdriver from selenium.webdriver.firefox.service import Service from selenium.webdriver.common.keys import Keys from...
17 May 2022 by 20PA1A04A9 YOSHITH
Problem Statement There are N students in a school with different capabilities. Sports teacher wants to form some teams of these students following the rule: Each team can have either 1 or 2 students. Capability score of each team is the sum...
2 Mar 2023 by 28. Nguyễn Ngọc Thùy Trâm
I want to write a program input a sequence positive integers and output the sequence in reverse order. What I have tried: I have tried this code: def reverse(string): string = list(string) string.reverse() return "".join(string)...
20 Oct 2020 by 2eding
def function1(W): n = W.shape[0] m = W.shape[1] keep = [] for i in range(m): mn = W[True - np.isnan(W[:,i]),i].mean() W[np.isnan(W[:,i]),i] = mn vr = W[:,i].var() if vr == 0: continue ...
31 Jan 2023 by 33-Prudhvi Ram Puppala
Given input as string . Python program to reverse the string What I have tried: N=input() For r in range(0,n): Reversestring=
20 Oct 2019 by 3razOr1993
I want to parse a xml file and save it as a txt file. My XML-File looks like follows: I am just interested in the attribute type inside the class ATTRIBUTE. I want just to display the values Demonstration and Portfolio in a text file
15 Sep 2020 by 5atyam5rivastava
The following code block runs for only 1 iteration. Giving the output : [1,9,8,7,6,5,4,3,2,10] Kindly help in resolving the logical bug. What I have tried: ''' Program to implement Selection Sort The time complexity of above algorithm is O(n^2)...
19 Feb 2022 by 723_Sahil Dhuri
there are many app which changes the voice in real time calling but there is no hint or open source to get an idea about it language preferred java(android studio),python What I have tried: I have tried recording voice and adding effect to it...
29 Nov 2022 by 74_Shubham Mourya [CO]
I am making cryptocurrency tracker and predictor web application for final year project. Can anyone please help me with what should i do:? We thought of making crypto tracker using APIs and predictive analysis model predicting the closing of...
13 Dec 2014 by 875ewh84
I want to write a program in Python which takes a C program as input, executes it against the test cases which are also as inputs and print the output for each test case. I am using Windows.
17 Dec 2014 by 875ewh84
I have developed by own grader for Xqueue(edX). It is a C compiler that pulls json objects from the Xqueue and pushes the results back into the Xqueue.I am returning a JSON response in the format expected (given below){ "correct": true, "score": 1, "msg": "The code passed all...
19 Dec 2014 by 875ewh84
inputfile.write("47");cmd = ["gcc", "-O2", srcname, "-o", execname];p = subprocess.Popen(cmd,stderr=errfile);errfile.close();#print(p)p.wait();...subprocess.call(["./"+execname],stdin=inputfile,stdout=outputfile)Above is some portion of my code to compile a C program using...
17 Jan 2015 by 875ewh84
my python code goes like this:def a(): ... ... subprocess.call() ... ...def b(): ... ...and so on.My task:1) If subprocess.call() returns within 3 seconds, my execution should continue the moment subprocess.call() returns.2) If...
10 Jun 2022 by 9998
Write a function S consisting of N letters 'a' or 'b'. This should return True if all occurrences of A are before all occurrences of b and return False otherwise What I have tried: S="aabbb" t=input("enter your text\n") if(t in S): ...
22 Nov 2011 by :)9/11
if (yourmum = buttonState.pressed) setvibration(playerindex.me,1,69)else { fatness++; }if (fatCountingUp > 300kg); (setBiggestLoserShow = true);else { (setBiggestLoserShow = MEGAtrue); }if (codDisc = broken); (YouDumpGirlfriend);else { ...
26 Nov 2019 by @Abdul Azeez Thekkekandy
This article explores Data Science lifecycles - Business Understanding, Data Understanding and Data Preparation
22 Jan 2023 by @Shubhpreet
Program to print the values of those bases and exponents whose exponentiation gives the same power value. Also print the corresponding power value. (Range: Initial value:- Base >= 2, Exponent >= 1 Terminal value: User Input ) Sample Input: ...
19 Oct 2022 by [0 0 0 0] 2022
When I run this code it gives me the error that 'pagesize' or any other part of the link with an & behind it is not a valid command/batch file. please help me Code: import os import json req = os.popen('curl -H "Authorization: Bearer [secret]"...
20 Oct 2022 by [0 0 0 0] 2022
im assuming the error has something to do with the encoding of the data (utf-8/16) Code: import os import json req = os.popen('curl -H "Authorization: Bearer USRllWyuqyO3KZpKNxKPAuQsMPoMS2qg5o"...
8 Jul 2021 by __Sahil__
While I am trying to insert a row to my table from the Tkinter Entry widget, I'm getting the following errors: Due to failed processing format-processing; Python "StringVar" cannot be converted to a MySQL type. This is our code so far : ...
18 Nov 2012 by __TR__
Refer these related threadshow-to-run-a-py(python)-file-in-asp-net[^]Call python script[^]
2 Jul 2013 by _Amy
You should start with A Byte of Python[^].--Amit
3 Aug 2014 by _Asif_
If you really are looking some serious stuff and have passion for it then my advice for you to start with VC++ because it is only VC++ that can you give you most of the flavor, whether its device driver development, desktop applications, web applications, server side applications, mobile...
14 Jan 2019 by _Asif_
This is indeed a vast subject. You can start from ANTLR[^] but do keep in mind that its just tip of the iceberg.
19 Jan 2022 by _Asif_
Try this, should give you an idea stack = [] lines='' textfile = open("jkl.txt","w") while lines!='stop': lines = input("Enter lines of input: ") if lines == 'stop': while len(stack) > 0: outString = stack.pop() +...
18 Feb 2022 by _Asif_
Change this D:/Pycharm/PycharmProjects/pythonProject/audio_assets/Chris hemsworth.mp3 To this D:/Pycharm/PycharmProjects/pythonProject/audio_assets/"Chris Hemsworth".mp3 should solve your problem, it would be great if you change Chris...
23 Feb 2022 by _Asif_
Don't understand why you want to do it recursively. Check below group = { "Duties & Taxes": "Current Liabilities", "Excise": "Duties & Taxes", "Bank Accounts": "Current Assets", "Branch / Divisions": "None", "Capital...
29 May 2013 by _frog_
Hello! I am beginner in Python programming and I want to make an application (GUI) in Python 2.6 + wxPython for process data stored in .mat files . (I make such data processing in MatLAB.) My application consists in:-selecting the path of the files process and the file i want to...
30 Apr 2021 by _gvsss
Write a program to get a string S, Type of conversion (1 - Convert to Lowercase, 2 - Convert to Uppercase) T, and integer P . Convert the case of the letters in the positions which are multiples of P.(1 based indexing). Input Description: Given a string S, Type of conversion T, and integer P ...
10 Oct 2019 by _gvsss
Given a string, print the run-length encoded output. Input Size : N
12 Oct 2019 by _gvsss
Write a program to give the following output for the given string S of size N.(character containing even number of occurences should be elaborated else print the same format) Eg 1: Input: a1b10 Output: a1bbbbbbbbbb Eg: 2: Input: b3c6d15 Output: b3ccccccd15 Input Size : 1
17 Oct 2014 by _Noctis_
Help you set and run gitstats on your windows
11 Apr 2022 by _ZΞTA
list1 = [5, 20, 15, 20, 25, 50, 20] as you can see the list has been declared, now what I've must do is 1. remove all the elements valued at 20 and save them in the variable list2. After that print the variable list2. 2. from variable list 2....
2 Apr 2022 by A Barnard
def isNarcissistic(x): """Returns whether or not a given number is Narcissistic. A positive integer is called a narcissistic number if it is equal to the sum of its own digits each raised to the power of the number of digits. ...
2 Apr 2022 by A Barnard
"def isComposite(x):\n", " \"\"\"Returns whether or not the given number x is composite.\n", "\n", " A composite number has more than 2 factors.\n", " A natural number greater than 1 that is not prime is called a...
14 Nov 2021 by A v Nov2021
Input in a text file: a=2*8 b=3*9 c=4*8 d=5*9 e=a+b f=c+d g=0*6 h=1*7 i=e+g j=f+h output=i+j Desired Output : output=(((2*8)+(3*9))*(0*6))+(((4*8)+(5*9))*(1*7)) What I have tried: #Logic from internet. D = dict() output = None with...
15 Nov 2021 by A v Nov2021
I have two text files. Text file 1 : 0=0.345,1=34.5,2=54.6,3=235.67 Text file 2 : (0+2)*(3+2) Is there a python operation that will assign the corresponding numbers from text file 1 to text file 2 ? I am doing my computations in text file 2...
16 Nov 2021 by A v Nov2021
Hi! (((13*(a7))+((12*(a6))+((11*(a5))+((10*(a4))+((8*(a2))+(9*(a3)))))))*(1*(a1))) Can you suggest me a regex logic to make all (a'integer') to be a'integer'? For the given line above my desired output is ...
6 May 2022 by A v Nov2021
The output of my code is as follows: 1 4 6 8 1 4 6 9 1 4 7 9 1 5 7 9 The desired output is as follows: 1 4 6 8 1 4 6 9 1 4 7 8 1 4 7 9 1 5 6 8 1 5 6 9 1 5 7 8 1 5 7 9 I want the loop to go through all possible combinations. Any help...
25 Apr 2022 by A v Nov2021
Input in a text file : Combination: 1 . 1 . 1 . 1 var_a: 33 op: -9.234727046103648 Combination: 1 . 1 . 1 . 2 var_a: 31 op: -9.234270216065962 Combination: 1 . 1 . 1 . 3 var_a: 39 op: -9.233204788566372 Combination: 1 . 1 . 1 . 4 var_a: 50 op:...
8 May 2022 by A v Nov2021
Given a csv file of different instances, how do I convert each instance to a xml file? Given : Instantiation, var_a,var_b 1,state0,state1 2,state0,state0 3,state1,state1 4,state1,state0 Output : 4 xml files with different names, each should...
2 Jun 2022 by A v Nov2021
df = pd.DataFrame({'A': [1,4,4,3,7], 'B': [1,2,2,6,4], 'C ': range(10, 5, -1)}) A B C 1 1 10 4 2 9 4 2 8 3 6 7 7 4 6 This is my data frame with 5 rows and 3 columns. I have to find a way to drop rows by...
30 Oct 2019 by A. B. Dinshaa
How to display a powerset using the following code? what is the mistake and where? why the output is not getting displayed? What to do to display the output? What I have tried: def power_set(items): N = len(items) # enumerate the 2 ** N possible combinations for i in range(2 **...
9 Nov 2019 by A. B. Dinshaa
def greedy_cow_transport(cows,limit=10): train = [] while sum(cows.values()) > 0: cart = [] total = 0 for cow, value in sorted(cows.items(), key=lambda x:x[1], reverse=True): if cows[cow] != 0 and value + total
9 Nov 2019 by A. B. Dinshaa
I hope that I can give the result you have specified. Using a list to display the answer and taking the input from a list written in the code are two different things that's why I mentioned dictionary. Displaying the output which you have specified from my question is easy and can be displayed...
26 Feb 2017 by A94
I a developing application in python that send email. When login credentials are passed as variables such that: "server.login(fromadd,password)" I get error that username and password not accepted. I have used gmail smtp server. But when I pass credentials such that:...
23 Oct 2015 by A94
I have a file which has some contents and I want to display only first word of each line from file. I tried but not getting.===========================file content===========================hello worldhi againpython programming is...
10 Dec 2016 by a_mboya
Country X calculates tax for its citizens using a graduated scale rate as shown below: Yearly Income: 0 - 1000 Tax Rate: 0% Yearly Income: 1,001 - 10,000 Tax Rate: 10% Yearly Income: 10,001 - 20,200 Tax Rate: 15% Yearly Income: 20,201 - 30,750...
18 Jun 2020 by AA0913
Hi All, I have a XML file where i need to read it and save each column to an excel file. Can someone pls help . I have some lines after the declare statement , But I want to parse from the table1 till /table1 can someone help me ?
13 Jun 2020 by Aaema Pirzada
import sys def min_refills(d, m, n, st, f): if d >= m: return 0 if m == 0: return -1 s = round(d/m, 3) si = int(d/m) sm = round(s - si, 3) n = len(st) y, i, r = 0, 0, 0 j = -1 o =...
24 Aug 2022 by Aalam Pratap Bedi
im getting this error in flask - ERROR in app: Exception on / [GET] What I have tried: from flask import Flask, render_template app = Flask(__name__) posts = [ { 'author': 'Corey Schafer', 'title': 'Blog Post 1', ...
25 Aug 2022 by Aalam Pratap Bedi
I have a folder named Python Project 01. It has 2 sub folders templates(for html)(it has two folders- home.html and about.html) and flaskblog (for python ) The code for my flaskblog is- from flask import Flask, render_template app =...
30 Aug 2022 by Aalam Pratap Bedi
{% for post in posts %} {{post title }} {{post author}} {% end for %} What I have tried: I am beginner in coding so i am just curios about this question.
5 Dec 2022 by Aalam Pratap Bedi
>>>pip install flask-login File "", line 1 pip install flask-login ^^^^^^^ SyntaxError: invalid syntax What I have tried: I am not sure how do I even proceed to solve this issue.
6 Dec 2022 by Aalam Pratap Bedi
(env0) C:\Users\AS\OneDrive\Documents\Python Project 01>python run.py Traceback (most recent call last): File "C:\Users\AS\OneDrive\Documents\Python Project 01\run.py", line 1, in from flaskblog import app ImportError: cannot...
10 Dec 2022 by Aalam Pratap Bedi
The error I'm getting- werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'home'. Did you mean 'main.home' instead? Code for my routes.py folder- from flask import render_template, request, Blueprint from...
29 Dec 2022 by Aalam Pratap Bedi
This is the error that shows up when I type command-"pip install -r requirements.txt" in "Ubuntu". Building wheel for cffi (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │...
18 Jan 2023 by Aalam Pratap Bedi
"requirements.txt" file- BareNecessities==0.2.8 bcrypt==4.0.1 blinker==1.4 certifi==2022.12.7 cffi charset-normalizer==3.0.1 click==8.1.3 cmake==3.25.0 Flask==2.2.2 idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.2 login==0.0.6 Mail==2.1.0...
6 Feb 2023 by Aalam Pratap Bedi
flask run --host=0.0.0.0 Traceback (most recent call last): File "/home/aalam/Flask_Blog/venv/bin/flask", line 8, in sys.exit(main()) File "/home/aalam/Flask_Blog/venv/lib/python3.10/site-packages/flask/cli.py", line 1047, in...
7 Feb 2023 by Aalam Pratap Bedi
flask run --host=0.0.0.0 Usage: flask run [OPTIONS] Try 'flask run --help' for help. Error: While importing 'run', an ImportError was raised: Traceback (most recent call last): File...
8 Feb 2023 by Aalam Pratap Bedi
ERROR in app: Exception on / [GET] Traceback (most recent call last): File "/home/aalam/Flask_Blog/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File...
9 Apr 2020 by Aarav Raj
i am working on a script that keep record of all http request that user are searched in the browser. and if the tab is changed then it should be record each and every request. What I have tried: i have tried some modules and also searching for...
1 Sep 2020 by Aarav Raj
I need to convert the Invoice PDF data into json format, but when i extract the daat from pdf it gives me in text format and when i convert them into json it convert the whole text in json ... but i need each one data sepretly. What I have...
16 Apr 2022 by aaron21345
Hello, I wanted to ask the python community for any useful online courses [Edx, Coursera, etc.] that they have had a positive experience with and would recommend. My background: My python knowledge is at a beginner/intermediate level and I...
1 Oct 2012 by Aarti Meswania
every one have different point of view for this questionsuppose comparing c# & vb, vb is easy for mefirst you should decide on which technology you want to work.language doesn't matter so muchlike real-world example, we can convert french, hindi etc languages to some other languages...
25 Jun 2013 by Aarutty
Can Someone suggest a best project for MCA. Steganograohy is impressive , but something else has to be added to it to make it little more outstanding.
17 Oct 2016 by Aarya001
QuestionI am getting o/p as desired but as you can see my phone numbers are listed as list in the file. but how do I extract only phone numbers from the mixed data and how do I display most frequent numbers from that mixed data.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed...
13 Nov 2022 by Aayush Jain 2022
a = 95 print(type(a)) a = str("a") print(type(a)) a = int(a) print(type(a)) What I have tried: I tried to convert int to string and than string to int I am facing issue on converting string to int
24 Dec 2022 by Aayush Jain 2022
num = int(input("Enter the number")) for i in range(1, 11): #print(str(num) + " X " + str(i) + "=" + str(i*num)) '''I understand the typecasting that on how we take user from input in form of int and we are converting in in str again but...
29 Dec 2022 by Aayush Jain 2022
num = int(input("Enter the number :")) for i in num (1,num+1): factorial = i*num print(f"{factorial}") #the question was to get factorial of a given number What I have tried: Please help me with why I am getting...
3 Jan 2023 by Aayush Jain 2022
a = [2,98,58,45] b = sum(a) print(b) #after printing b i am getting sum of above #I assume that python itself identifies sum as a function to add #please be simple in your answer if my assumption is right logically What I have tried: I...
21 Jan 2023 by Aayush Jain 2022
class Employee: company = "Google" def getSalary(self, signature): print(f"Salary for this employee working in {self.company} is {self.salary}\n{signature}") harry = Employee() harry.salary = 100000 harry.getSalary("Thanks!")...
9 Apr 2023 by Aayush Jain 2022
import os if __name__ == '__main__': x = input("What you want me to pronounce") command = f"say {x}" os.system(command) #can I run this on windows or it can be run on MAc only What I have tried: checking...
18 Jun 2022 by Abbas Harb
Hello everybody! I want to use a trained hdf5 model in c# using vs2022. What I have tried: I tried to use some python projects that converts keras2onnx, but I don't know python. I faced a lot of problems dealing with tensorflow libraries and...