[Solved] Root of quadratic polynomial with Python

First read the input from the command line (hint : use sys.argv). Also you will need to figure out how to convert strings to python numbers. Then check if b**2-4*a*c < 0. If yes, then raise a ValueError about that there are no real roots. Else solve for the roots: roots = (b ± sqrt(b**2-4*a*c)) … Read more

[Solved] Trouble with call function [closed]

Python is dependant on indentation. In order for the program to work you need to add the correct indentation to your code. That involves 4 spaces for each loop or flow control. Here are a few that do: def if while for Your problem is that Python does not know where to end the while … Read more

[Solved] Better way of replacing subtring from a string [duplicate]

When manipulating structures such as URLs it’s better to use tools designed for the purpose rather than treating them as strings. In this case you want to change the host (netloc) to www.site2.com So… from urllib.parse import urlparse, urlunparse new_site=”www.site2.com” url=”https://www.site1.com//vehicles/2023/Ford/F-150/Calgary/AB/57506598/?sale_class=New” scheme, _, path, params, query, fragment = urlparse(url) new_url = urlunparse((scheme, new_site, path.replace(‘//’, “https://stackoverflow.com/”), … Read more

[Solved] How to rotate xticklabels in a seaborn catplot

The correct way to set the xticklabels for sns.catplot, according to the documentation, is with the .set_xticklabels method (.e.g. g.set_xticklabels(rotation=30)). Using a loop to iterate through the Axes, should be used if changes need to be made on a plot by plot basis, within the FacetGrid. Building structured multi-plot grids seaborn.FacetGrid g or in the … Read more

[Solved] Can someone tell me what this statement does? [closed]

a.strip().split() produces a list of strings of the form ‘a-b’ where the a and b are composed of digit characters. This means that: alignment = set([tuple(map(int, x.split(“-“))) for x in a.strip().split()) produces a set from a list defined by a list comprehension. The list comprehension takes each of these ‘a-b’ strings, spits it into two … Read more

[Solved] How to convert 12 hour string into 24 hour datetime? [closed]

The main problem with your format is that Python does not support anything more granular than microseconds, as explained here. In fact, assuming you have 000 as the last three decimals of seconds, you can use the format below. from datetime import datetime datetime_object = datetime.strptime(’24/NOV/18 05:15:00.000000000 AM’, ‘%d/%b/%y %I:%M:%S.%f000 %p’) If you cannot make … Read more

[Solved] How can I procees the below text file for text classification? I would like each paragraph as a row in a pandas dataframe, I am unable to do that [closed]

f = open(‘sample_text.txt’, ‘r’) data = f.read() paragraphs = data.split(“\n\n”) paragraphs[:] = (value for value in paragraphs if value != ‘\t’) 2 solved How can I procees the below text file for text classification? I would like each paragraph as a row in a pandas dataframe, I am unable to do that [closed]