Write me python code that gets the price of msft using yfinance
- User
Write me python code that gets the price of msft using yfinance
Assistant
To get the price of MSFT using the yfinance library in Python, you can use the following code:
import yfinance as yf # Initialize the ticker object for MSFT ticker = yf.Ticker("MSFT") # Get the current price price = ticker.info["currentPrice"] # Print the price print("The current price of MSFT is:", price)This code first imports the yfinance library, then initializes a ticker object for MSFT. It then retrieves the current price of MSFT and prints it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.