Found 6 Questions for WX Python

How to increase/reduce the fontsize of X and Y tick labels in Matplotlib?

Rishikesh Kumar Rishi
Updated on 11-May-2021 13:16:36
To increase/reduce the fontsize of x and y tick labels in matplotlib, we can initialize the fontsize variable to reduce or increase font size.StepsCreate a list of numbers (x) that can be used to tick the axes.Get the axis using subplot() that helps to add a subplot to the current figure.Set ticks on x and y axes using set_xticks and set_yticks methods respectively and list x (from step 1).Set tick labels with label lists (["one", "two", "three", "four"]) using set_xticklabels() and set_yticklabels() with fontsize variable.To add space between axes and tick labels, we can use tick_params() method with pad argument that helps to ... Read More

How to convert a .wav file to a spectrogram in Python3?

Rishikesh Kumar Rishi
Updated on 11-May-2021 12:25:40
To convert a .wav file to a spectrogram in python3, we can take the following steps −Load a .wav file from local machine.Compute a spectrogram with consecutive Fourier transforms using spectrogram() method.Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.Use imshow() method with spectrogram.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt from scipy import signal from scipy.io import wavfile plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True sample_rate, samples = wavfile.read('test.wav') frequencies, times, spectrogram = signal.spectrogram(samples, sample_rate) plt.pcolormesh(times, frequencies, spectrogram, shading='flat') plt.imshow(spectrogram) plt.show()OutputRead More

Can someone help me fix this Python Program?

Arnab Chakraborty
Updated on 24-Jun-2020 07:26:01
The first problem u are getting in the bold portion is due to non-indent block, put one indentation there.second problem is name variable is not definedfollowing is the corrected one -print ("Come-on in. Need help with any bags?") bag=input ('(1) Yes please  (2) Nah, thanks   (3) Ill get em later  TYPE THE NUMBER ONLY') if bag == ('1'): print ("Ok, ill be right there!") if bag == ('2'): print ("Okee, see ya inside. Heh, how rude of me? I'm Daniel by the way, ya?") name="Daniel" print (name + ": Um, Names " + name) print ("Dan: K, nice too ... Read More

How to send the result of Python CGI script to the browser?

Arnab Chakraborty
Updated on 22-Jun-2020 15:37:06
# Get data from fields from HTML page first_name = form.getvalue('first_name') last_name  = form.getvalue('last_name') send data to Browser print("Content-type:text/html") print print("") print("") print("Hello - Second CGI Program") print("") print("") print(" Hello %s %s " % (first_name, last_name)) print("") print("")

How to use enums in Python classes?

Arnab Chakraborty
Updated on 23-Jun-2020 14:47:21
There is a module name "enum" in python with the hep of which enum is used in python.#import enum import enum # use enum in class class Car(enum.Enum):    suzuki = 1    Hyundai = 2    Dezire = 3 print ("All the enum values are : ") for c in (Car):    print(c)

How i can replace number with string using Python?

Malhar Lathkar
Updated on 20-Jun-2020 09:05:51
For this purpose let us use a dictionary object having digit as key and its word representation as value −dct={'0':'zero', '1':'one', '2':'two', '3':'three', '4':'four',      '5':'five', '6':'six', '7':'seven', '8':'eight', '9':'nine'Initializa a new string object newstr=''Using a for loop traverse each character  ch from input string at check if it is a digit with the help of isdigit() function. If it is digit, use it as key and find corresponding value from dictionary and append it to newstr. If not append the character ch itself to newstr. Complete code is as follows:string='I have 3 Networking books, 0 Database books, and 8 Programming ... Read More
1
Advertisements