liveBook · Manning

String

As explained in A Pythonic Adventure: From Python basics to a working web app

A string is a sequence of text characters represented as a value in a program.

A string is a word or several words stored as a program value. Put text inside quotation marks, such as "Welcome to Erik's Coffee Shop!". Strings are common arguments for functions such as print() and input(). section 1.2

Strings become useful immediately in a small coffee-shop application:

  • Pass a string to print() to show a message. section 1.2
  • Save a function's returned string in a variable, then use that variable later. section 1.2
  • Remember that keyboard input arrives as a string; convert it before doing mathematical operations. section 2.1

Your coffee-shop order

name = input("Please enter your name: ") drink = input("Please enter your drink: ") print("Here is your order, ", name) print("Main product: ", drink) section 1.2

Listing 1.1 The first version of the coffee shop application
print("Welcome to Erik's Coffee Shop!")
 
name = input("Please enter your name: ")
drink = input("Please enter your drink: ")
flavor = input("Please enter your flavor: ")
topping = input("Please enter your topping: ")
print("Here is your order, ", name)
print("Main product: ", drink)
print("Flavor: ", flavor)
print("Topping: ", topping)
print("Thanks for your order!")

Use the complete coffee-shop listing to trace strings from prompts into variables and printed order details. section 1.2

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Defines strings through prompts and output, then stops short of detailed string operations.
Examples
Demonstrates coffee-shop prompts, names, drinks, flavors, toppings, welcome messages, and order summaries.
What it assumes
Teaches strings alongside functions, arguments, variables, and keyboard input from introductory examples.
What you can do after
Apply strings via Python to prompt users, store responses, and print personalized messages.
How it connects
Connects strings with functions, arguments, variables, input, lists, and numbers.

Also explained in

Compare how 24 books explain string →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.