[Solved] How do i have the program print a different response each time? [closed]

You can try using the random.choice() function provided by the random module: import random greetings = [“How are you!”, “Why are you?”, “What are you?”] print(“Hi, “, input(“What is your name?”), random.choice(greetings)) This will give you random choices from the greetings list everytime. solved How do i have the program print a different response each … Read more

[Solved] How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose

How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose solved How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose

[Solved] Questions about lambda and eval in relation to some Python calculator GUI code [closed]

Assigned variables are just that. Assigned by the coder. I have variable_name = object. If there are Tkinter specific variables being used at some point it is most likely a PSEUDO-CONSTANT that is used in arguments within the methods of tkinter. You should never try to change predefined variables that are part of the tkinter … Read more

[Solved] how to extract digits from a string? [closed]

Based on the expected output, you want more than just digits. The digits can have /, – and ,. Maybe, perhaps, you wanted something that starts with and ends with a digit, but anything in the middle other than a space? import re a=”invoice β invoice # 2018-33167-2 β date 03/21/2018 β total due $8,804.90″ … Read more

[Solved] Filtering files with python [closed]

This is basically the same as Levon’s answer, but slightly more compact and Pythonic, and with the numbers adjusted to a guess at what I suspect the OP is trying to do. with open(‘data.txt’) as inf: for lc, line in enumerate(inf): # lc – current line count if lc >= 2: # netstat usually has … Read more

[Solved] How can I analyse an response.text in Python?

As you have a dictionary of dictionaries, accessing each dictionary value will give you another dictionary. You can then access the values from that dictionary in the same way. For your particular example, you can do the following: >>> master_dict[“Item”][“last_data”][“S”][“question”] ‘question question question?’ If instead, you want to access all occurrences of a certain key … Read more

[Solved] Get stock data problems [closed]

There’s nothing wrong with your code. However recent stock data is a Premium product from Quandl and I presume you are just on the free subscription, hence your dataframe comes back empty. If you change the dates to 2017, you will get some results but that’s as far as it goes on the free subscription … Read more

[Solved] I am trying to write an encryption in Python. My Problem is that the key is shorter than the message. Therefore I should start again with the key

I am trying to write an encryption in Python. My Problem is that the key is shorter than the message. Therefore I should start again with the key solved I am trying to write an encryption in Python. My Problem is that the key is shorter than the message. Therefore I should start again with … Read more

[Solved] For Loop executed every 5 minutes for 24 hours

Something like this? The loop runs for (a little more than) twenty-four hours and sleeps for five minutes after each iteration. from time import sleep, time ONE_DAY = 24 * 60 * 60 # seconds FIVE_MINUTES = 5 * 60 # seconds start_time = time() current_time = start_time while current_time <= start_time + ONE_DAY – … Read more

[Solved] What is wrong with my “summarize” command?

Python is not Java. You don’t need setter functions for every property. Use the __init__ method to initialize your object: class Textbook: def __init__(self, title, author, publisher, year, course, semester): self.title = title self.author = author self.publisher = publisher self.year = year self.course = course self.semester = semester def summarize(self): s=”{:40s} {:15s} {:15s} {:4d} {:8s} … Read more