Click here to Skip to main content
15,914,820 members
Everything / Programming Languages / Python3.3

Python3.3

Python3.3

Great Reads

by Bill_Hallahan
This is a Python 3.x code generation program that generates Python 3 programs.
by nikesh singh
In this article, you can find a tutorial for a simple Flask app with Python codes

Latest Articles

by Bill_Hallahan
This is a Python 3.x code generation program that generates Python 3 programs.
by nikesh singh
In this article, you can find a tutorial for a simple Flask app with Python codes

All Articles

Sort by Score

Python3.3 

27 Jan 2022 by M Imran Ansari
You can achive this through using join(), split() + list of censors words. You code like be userText = input("Enter some Text to be Censored: ") # Initialization of censors words list and replaced by censors_words = ['dang', 'darn', 'freak']...
15 Oct 2023 by OriginalGriff
Look closely at your code: while True: ... result+=term k=+1 ^^ || return result That assigns +1 to k I suspect you wanted this: while True: ... result+=term k+=1 ...
18 Jan 2021 by Patrice T
Quote: I am getting indentation in this basic code in Python can someone explain this ? Did you forgot the word 'Error' ? Try import cmath a = 1 b = 5 c = 6 # calculate the discriminant d = (b**2) - (4*a*c) if d > 0: sol1 =...
14 May 2024 by Pete O'Hanlon
Richard's comment to you is more important than you might think. Suppose we do the work for you, and write the code for you, what would you actually learn from this? You certainly wouldn't have learned the thought process behind how we would...
18 Jun 2019 by OriginalGriff
There is a pretty big clue in what your teacher gave you: # Hint: Type return a+b below Literally all you have to do is remove the "# Hint: Type " and "below" bits and it'll work... You are never going to pass this course unless you read carefully, and start thinking ... honest!
24 Jun 2019 by Thomas Daniels
= is the assignment operator. You want ==, the equality operator.
6 May 2020 by CPallini
Try mac_address_search_result = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", ifconfig_result.decode('utf-8'))
12 Apr 2021 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
13 Apr 2021 by CPallini
The following program (Python 3) s = input() lnum = list(map(int, s.split())) print("Unsorted:", lnum) print("Sorted Ascending Order:") print (sorted(lnum)) print("Sorted Descending Order:") print(sorted(lnum, reverse=True)) executes this...
7 May 2021 by Richard MacCutchan
You need to do what it says in the comment on line 12.
25 Jan 2022 by M Imran Ansari
Very Clear, some of your lines in code don't have valid float data. Best way to find the error is implement exception handling in your code. Python Exception Handling Using try, except and finally statement[^] Or print some log/message to find...
24 Jul 2022 by Richard MacCutchan
list = [3,0,1,-2] for i in range(1, len(list)): list[i] += list[i - 1] print(list) Produces: python atest.py [3, 3, 4, 2] Python test result: 0
10 Nov 2022 by Bill_Hallahan
This is a Python 3.x code generation program that generates Python 3 programs.
14 Oct 2023 by OriginalGriff
Because this test always passes: if line == "done" or "Done": because in Python any non-empty string is True and the second part of your condition is just a string literal. Change it to this: if line == "done" or line == "Done": and it'll get to...
18 Dec 2023 by Dave Kreskowiak
First, you don't have to specify an else if there's nothing to do outside of the conditions you've been given. Next, the program spec says Quote: Write a function giving the sum of the integers of [1,N] divisible by 3 or 5. You might want to...
10 Sep 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
10 Sep 2018 by Richard MacCutchan
See The Python Tutorial — Python 3.4.9 documentation[^]
4 Dec 2018 by Richard MacCutchan
The second loop tries to repeat for the range (2,2) in the first iteration. Which is effectively while x is greater than 2 and less than 2: but that is impossible so the loop terminates. So the output starts at 3 which is the next iteration of the outer loop when n has a value of 3. If you look...
12 Dec 2018 by Richard MacCutchan
The second test below should just be if, not elif. if maxa[i]: min=a[i]
12 Dec 2018 by CPallini
The lazy people solution import random a = [random.randint(-100,100) for i in range (10)] print(a) a.sort() print(a[-1],a[0])
18 Jun 2019 by Richard MacCutchan
The Python Tutorial — Python 3.7.3 documentation[^]
8 Sep 2019 by Patrice T
Quote: Code is ready and working, but GIT shows incorrect as far as I can see, your usage of 3 spaces as indentation is perfectly legal, but Git want 4 spaces. "indentation is not a multiple of four"
11 Sep 2019 by Patrice T
Sure, I can just give you a full blowup solution, but I am not sure you will learn something. As it is very basic understanding of Python and programming, I think it is better to give you leads and a link to a good tutorial. # Because of print(dec_to_binary(145)) # -> 10010001 # and ...
11 Sep 2019 by Richard MacCutchan
Try the following. You may need to modify some part of it to meet your own criteria, but it does the basics. def binary_to_dec(binary: str) -> int: """ Uses the ord() builtin to get the numeric value of a character Subtracting the ord('0') gets the integer value of the digit ...
31 Jan 2020 by Richard MacCutchan
You forgot the parentheses in your call to create an instance of the class Laptop. It should be: class student : def __init__(self,name,rno) : self.name=name self.rno=rno self.Lap=self.Laptop() #
7 Feb 2020 by Patrice T
First a typo: "But the answer is 49, which means 7*7" Quote: I'm trying to compute the nearest square of a number less than a limit using python. If limit is 36, which answer do you expect 25 or 36 ? Quote: It works, the output answer is 36. But I'm still a little bit confused about the...
3 Apr 2020 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
9 Jul 2020 by Richard MacCutchan
Of course it does, as you are passing parameters by position and not by name. So if you reverse the order in line 12 then they will be reversed when they are received by c1's constructor. If you want the values to be referred to by name then your...
11 Jul 2020 by OriginalGriff
Apart for not compiling as is, so the code sample you show won't work, give it a try: replace the "if" with a print statement and show the values of i and j. Whichever goes up first is the inner loop.
11 Jul 2020 by Richard MacCutchan
Using a simple example we get the equivalent shown here: x = [ 2, 3, 4, 7, 11 ] z = [j for i in x for j in range(len(x)) if i == x[j]] print(z) # which is the same as zzz = [] for i in x: for j in range(len(x)): ...
16 Sep 2020 by OriginalGriff
Why do you think? What would change if you didn't? Do two things: 1) Read this: Binary search algorithm - Wikipedia[^] And 2) Break out the debugger and follow your code through as is. Now change "m + 1" to "m" and try it again. What changed?...
16 Sep 2020 by Richard MacCutchan
The same answer as you were given four days ago at https://www.codeproject.com/Questions/5279256/Why-do-we-add-1-to-the-r-plus-m-in-the-last-line[^]. Did you follow the suggestions?
16 Sep 2020 by Patrice T
Same question as Why do we add 1 to the r + m in the last line ?[^] with mostly same code. m+1 is not alone it foes with other variables: elif lst [ m] > key : return bsearch2 ( lst , key , lo , m ) else : # lst[m]
1 Nov 2020 by Richard MacCutchan
Quote: can anyone give me the best approach to this question?? Read through the instructions to see what classes of objects you need to create. The first item in the instructions is a state, which contains some number of cities. So you need a...
18 Jan 2021 by OriginalGriff
In Python indentation is significant: identically indented lines of code form a block of code which is executed together. So when you do an if ... else statement, all teh lines that are executed when the condition is true must share teh same...
19 Jan 2021 by CPallini
Complex math takes care of the discriminant sign, so you may write import cmath sol1 = (-b-cmath.sqrt(d))/(2*a) sol2 = (-b+cmath.sqrt(d))/(2*a) print('The Solutions are {0} and {1}'.format(sol1, sol2)) Using the traditional ('real' math)...
9 Feb 2021 by CPallini
from "The Code Conversion Service": :-) #include using namespace std; string caesar( string message, int shift) { string result; for (auto c : message) { if ( c >= 'a' && c
12 Feb 2021 by OriginalGriff
Try this: grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O',...
12 Apr 2021 by Patrice T
Quote: i tried but failed to get answer. The help you want is us to do the job. You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork....
20 May 2021 by OriginalGriff
Start by learning Python: it is an unusual language in that indentation is significant - it determines what code is part of what. So when you create a function, all the code in the body of the function must be indented to the same level (or...
2 Nov 2021 by Richard MacCutchan
Start by looking closely at each question. a. refactor the script into a function, get_grades() - so you need to create a function which returns a dictionary: def get_grades(): grades = {} # declare an empty dictionary # add the code...
7 Nov 2021 by OriginalGriff
+You get an error because the function requires at least two parameters, num1 and num2 Since you provide only one, the system can't call the function and raises an error instead.
12 Dec 2021 by OriginalGriff
Read the error message, it is pretty clear: File "C:/Users/user/Desktop/car dealer/car dealer.py", line 505, in Add_car self.insert_photo = self.convert_image_into_binary(photo) NameError: name 'photo' is not defined So it's line 505, in...
28 Jan 2022 by Manuel L. Monge
vr20222, It's much simpler that what you have produced... my_keys = {"id","tiCustomField_CDP Neighbors"} res = {} l = [] for i in y: res = {my_key:i[my_key] for my_key in my_keys} l.append(res) print(l) You'll note that I reversed...
6 Mar 2022 by OriginalGriff
Your code is unreadable: when you paste code, you need to use the "Paste as" option "Code Block", or use the codewidget on the toolbar above the text box. That tells the system that characters are part of your code and shouldn't be...
8 Apr 2022 by markkuk
The map() function[^] returns an iterator and you must convert it to a list before you can serialize it. return JsonResponse(list(sw_list), safe=False)
15 Jun 2022 by OriginalGriff
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings, you cause...
25 Jul 2022 by OriginalGriff
In general, there is no way for software to destroy the motherboard it is running on: this is considered as a design feature as it prevents malicious morons from releasing software which does just that to unsuspecting users ...
25 Jul 2022 by 0x01AA
Never expected that you like to do that what @OriginalGriff brings up. In that case, even it is not programmatically I suggest a screwdriver, maybe there is a Python version of it.... Btw. I could not resist, down votes expected ;p
3 Jan 2023 by OriginalGriff
JSON isn't a database: That's not a database, dude![^] To "merge" JSON files, they all need to be using the same data structure (not guaranteed) and require you to either load the JSON data into python classes and merge those before generating a...
13 Apr 2023 by Richard Deeming
You're making a GET request to the delete_image route, using an tag, so you won't be able to include hidden fields in the request. But endpoints which create, change, or delete data should never accept GET requests. Some browsers or...
7 Oct 2023 by OriginalGriff
Neither of your distance or area functions return a value:, but the code calling the functions expects them to. See here: Python Function Return Value[^] and try this: import math def distance (x1,y1,x2,y2): horizontal=x2-x1 ...
24 Oct 2023 by Richard MacCutchan
Yes because unless the first character in the word matches the letter, the while loop will continue until the end of time. I don't expect you want to wait that long. You need to increment the index in your while loop each time you test a...
24 Oct 2023 by OriginalGriff
Quote: The following program does not run. Please don't ask me to debug the code myself. I am unable to. Which means "I found this on the internet, and I can't be bothered to work out how it works - so fix it for me" without telling us anything...
24 Oct 2023 by CPallini
Richard already gave you the correct solution. As an alternative, you may use the count method of the string type: number = "mississippi".count("s") print('There are', number, '"s" characters')
24 Oct 2023 by M Imran Ansari
In the current functionality, the function find is intended to find the index of a particular letter in a given word. To count the number of occurrences of a letter in a given word, you can modify the find function to iterate through the entire...
26 Oct 2023 by OriginalGriff
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens - and "I get error" means just that - "it doesn;t work"! So tell us what it is doing that...
18 Dec 2023 by CPallini
Quote: i dont know what to write in the else part First, you have to fix your ifcondition. As suggested, look again at the requirement. See if your code complies. The else part is optional, if you don't need it, then omit it.
10 Aug 2018 by Member 13945270
Here is the sample code snippet - conn = httplib.HTTPConnection("proxy_IP",proxy_port) conn.set_tunnel(host,80) conn.request("POST", parameter1, parameter2, parameter3) response = conn.getresponse() I am trying to tunnel the web request sent to my host through a proxy server. The problem is,...
18 Nov 2018 by Member 14059398
I have compatibility openpyxl and pyxlsb, using openpyxlI have done some code to style the cells accordingly but I need to compress the code or just avoid nested for loops or itertools. For following requirements I have tried code: What I have tried: 1) Here for 1st row i need to get...
19 Nov 2018 by Member 14060132
Hello, Basically currently my program reads the Data file (electric info), sums the values up, and after summing the values, it changes all the negative numbers to 0, and keeps the positive numbers as they are. The program does this perfectly. This is the code I currently have: import csv from...
19 Nov 2018 by Richard MacCutchan
Not sure I understand the issue. But once you have done the first set of calculations you can read the datafile and do the cumulative calculations. Once you have those you can then write out the new data.
22 Nov 2018 by Richard MacCutchan
I explained this to you yesterday, and gave you a link to the documentation for csv.writer.
23 Nov 2018 by Richard MacCutchan
The Python Tutorial — Python 3.4.9 documentation[^]
23 Nov 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
23 Nov 2018 by Patrice T
Quote: i dont know how to do it. It start to be a rather advanced project (for school), but still simple for a professional programmer. You can't just "don't know how to do it" or be confused, or there is a problem in the course you follow, you may have to speak with your teacher. Programming...
4 Dec 2018 by bswarrior
I've tried two loops samples but ı didint understand why when"loop1" starts from "3", "loop2" starts from "2"? ı supposed that both should have been the same. Here is the output: 3 prime 4 = 2 * 2.0 5 prime 2 prime 3 prime 4 = 2 * 2.0 5 prime What I have tried: def...
12 Dec 2018 by Patrice T
A problem in your code is that you are guessing that you will values both over and under zero. max=0 min=0 What if all values are between 10 and 100 ? you need to initialize min and max with the first random value.
10 Apr 2019 by Member 11907260
I'm getting "Unhashable Type : Index" error in python code. i'm using python3 . Can you please help me to resolve this problem? code- df_temp_cns = pd.read_excel(r"/nsmnt/NS_Exec_DSHBD/IS_IT_Demad_Perf/cns_weekly/SrcFile/JnJ_CNS_Weekly_No_Indication_WE_2019-01-25.xlsx", header=0,...
10 Apr 2019 by CPallini
See Select Rows & Columns by Name or Index in DataFrame using loc & iloc | Python Pandas – thispointer.com[^].
18 Sep 2019 by Akash Tawade
I am executing one code with speech recognition python library....then after run it comes say "Please build and install the PortAudio Python bindings first". then i install pyaudio library but same error comes. What I have tried: `r = sr.Recognizer() with sr.Microphone() as source: ...
9 May 2019 by OriginalGriff
We have no idea what data you provide to get the error, what the error is, what teh answer should be, ... anything at all really! So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on...
6 Jun 2019 by Member 13807140
Hello guys, I have a problem with the following: I testing Python with selenium web driver. I need download data of different web page, the schema is the same in all pages, the difference is in the URL, since the last value is variable, it can be a number between 1 and 100. These URLs are...
9 Jun 2019 by Member 14489730
I'm trying to merge the object based on key specs, most of the keys structure is consistent, taking into consideration the merge will only happen if company_name is the same (in this example, I only have one company_name) and if only (name, {color, type, license, description) are equal across...
2 Dec 2020 by JAI_C
def solveMeFirst(a,b): # Hint: Type return a+b below num1 = int(input()) num2 = int(input()) res = solveMeFirst(num1,num2) print(res) What I have tried: i have tried to run it and it is showing this error num1 = int(input()) ^ IndentationError: expected an indented block I am...
18 Jun 2019 by Thomas Daniels
The solveMeFirst method is empty (a comment does not count as "code"). Therefore, Python's thinking is "there still has to be code" and the next code it notices, is not indented as per Python's indentation rules. So, put some code in the function. In fact, the comment tells you exactly what to...
5 Jul 2019 by OriginalGriff
Repost: deleted. Please do not post the same question multiple times.
5 Jul 2019 by OriginalGriff
Repost: deleted. Please do not post the same question multiple times.
11 Jul 2019 by Subham Subhasis Patra
' = ' this is used for assignment operator,, but you need ' == ' for comparison .. thats why it show an invalid syntax error .. and check you ' code indentation '
11 Jul 2019 by Subham Subhasis Patra
' = ' this is used for assignment operator,, but you need ' == ' for comparison .. thats why it show an invalid syntax error .. and check you ' code indentation
19 Jul 2019 by Raman_patil
I wanted to copy the content of one docx/document to another docx/document at particular position. Note: Content might be having text data with background color, tables, smartart and images. What I have tried: def add_para_data(output_doc_name, paragraph): """ Write the run to the...
8 Sep 2019 by martinfilikas
I have made a program, which calculates the area of Circle, Square and Triangle. The code is working if i press "run" command in Pychram. But when i upload it to git i get an email, that shows, the code is completely incorrect. The code: """Ask user a shape and a radius or a side length and...
11 Sep 2019 by martinfilikas
I need to convert decimals to binary and binary to decimals but i get all the time wrong answers. I am not allowed to use bin and other built in statements in Pycharm that could help me to convert answer. """Converter.""" def dec_to_binary(dec: int) -> str: """ Convert decimal number...
7 Nov 2019 by Mujan1358
I have a data frame, with students ID and names and other information. I have done a groupby on students ID, I need to create zip file(on student name) for each student and then zip them all. I have the following code. I can zip all the csvs, but how can I zip each individually first since...
7 Nov 2019 by Richard MacCutchan
See Data Compression and Archiving — Python 3.8.0 documentation[^]
8 Dec 2019 by Md Razeenuddin Mehdi
We have been give a problem to add two numbers without the + operator and using XOR, AND and from sys import stdin,stdout T = int(stdin.readline().strip()) for itr_t in range(T): ...
2 Jan 2020 by SaadShaban3
I have an (20x4) ndarray and i need to rotate every 4 rows from beginning to form a new ndarray which has size of (5x16). For simplicity, here is a sample of the original data and the intended resulting data with random contents just to infer the way of transpose: original ndaaray: 0 1 2 ...
31 Jan 2020 by Ravikumar Mk
class student : def __init__(self,name,rno) : self.name=name self.rno=rno self.Lap=self.Laptop def show(self) : print(self.name,self.rno) self.Lap.show() class Laptop: #inner class def __init__(self) : self.brand="hp" self.cpu="i5" self.ram=8...
31 Jan 2020 by OriginalGriff
You don't need to pass self to a function: it's there in all classes automatically - it's the current instance of the class that contains the function. Think of it like cars: all cars have a glove box, so you could write a function to add or remove an item from it - but you don't need to pass...
7 Feb 2020 by lock&_lock
I already finish the task, just need an explanation. I'm trying to compute the nearest square of a number less than a limit using python. Let's say if my limit is 40, then the nearest square would be 36 (from 6*6). What I have tried: I already found the answer, but need some explanation : ...
20 Feb 2020 by Richard MacCutchan
shapes not aligned - Google Search[^]
12 Mar 2020 by Richard MacCutchan
Try this: def main(i,j): m=[] l=list(range(i)) for count in range(j): m.append(l) return m array = main(8, 3) for x in array: print(x)
3 Apr 2020 by Member 14791717
import requests from bs4 import BeautifulSoup import re import json def lol(url): with requests.Session() as req: r = req.get(url) soup = BeautifulSoup(r.content, 'html.parser') vs =...
10 Apr 2020 by OriginalGriff
We have no idea. Talk to anaconda3 - whoever they are - and they may be able to help. But we can't - we have access to their systems ...
11 Apr 2020 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us...
18 Apr 2020 by Major Morph
Hello Everyone! I recently started with Django and I found a project on GitHub and I downloaded it and started working on it but it was created with Django version 1.4.2 is there any way to upgrade the whole project in the new version of Django...
18 Apr 2020 by Maciej Los
Django 1.4 release last term support ended with october 2015. See: Download Django | Django[^] You have to update your code accrodingly to the current version of Django installed on your OS. Quote: I have tried to modify the files manually...
31 May 2020 by A. B. Dinshaa
File "", line 37 sql_create_projects_table = CREATE TABLE IF NOT EXISTS ACTOR { ^ SyntaxError: invalid syntax when I write: sql_create_projects_table = CREATE...
31 May 2020 by OriginalGriff
Shouldn't that be a string? It's trying to process your SQL command as Pyuthon code ...
10 Jul 2020 by Ahmad Qassym
class cl: def __init__(self,x,y): self.x = x self.y = y def multiply(self,n): self.x = self.x * n self.y = self.y * n class Cam(cl): def __init__(self,g,x,y): self.g = g ...