In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Python Hello World and string operation example analysis, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method. Open
So, let's get started! If you are confused, I suggest you open the video below in a separate tab.
Hello World and string manipulation video of Python
Start (prerequisite)
First install Anaconda (Python) on your operating system. You can download anaconda from the official website and install it yourself, or you can install it by following these anaconda installation tutorials.
Install Anaconda on Windows: [link 5
Install Anaconda on Mac: link
Install Anaconda on Ubuntu (Linux): link
Open a Jupyter Notebook
Open your terminal (Mac) or command line and type the following (see 1:16 in the video) to open Jupyter Notebook:
Jupyter notebook print statement / Hello World
Type the following in the cell of Jupyter and press shift + enter to execute the code.
# This is an one line commentprint ('Hello Worldwide')
Printout "Hello World!"
Strings and string operations
A string is a special type of the Python class. As an object, in the class, you can use .methodName () to call the method of the string object. String classes are available by default in Python, so you don't need import statements to use the string object interface.
# Create a variable# Variables are used to store information to be referenced# and manipulated in a computer program.firstVariable = 'Hello World'print (firstVariable)
Output print variable firstVariable
# Explore what various string methodsprint (firstVariable.lower ()) print (firstVariable.upper ()) print (firstVariable.title ()
Output using the .lower (), .upper (), and title () methods
# Use the split method to convert your string into a listprint (firstVariable.split (''))
Output using the split method (separated by spaces in this example)
# You can add strings together.a = "Fizz" + "Buzz" print (a)
String concatenation
The function of query method
For new programmers, they often ask you how to know the function of each method. Python provides two ways to do this.
1. (available not in Jupyter Notebook) use help to query the functionality of each method.
Query the function of each method
2. (for Jupyter Notebook only) you can also find the function of a method by adding a question mark after the method.
# To look up what each method does in jupyter (doesnt work outside of jupyter) firstVariable.lower?
Find the function of each method in Jupyter
This is the answer to the example analysis question about Python Hello World and string operation. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.