Let’s Learn together:
To create a simple brand name generator program using python, we need to be aware of the below topics
- Print function
- String Manipulation
- Input Function
Print is a simple function, which gets the string that needs to be printed as an input and prints the sting as an output
print (“String that needs to be printed”)
String manipulation is basically printing the string in the needed format
To print multiple words in a new line as below
Testing 1 Testing 2 Testing 3
For this, we can simply use the below technique, instead of writing 3 print statement
print (“Testing 1 \n”+”Testing 2 \n”+”Testing 3”)
The input function helps to get input from the user and this input can be later used in our code logic
input(“Where are you from”)
The above statement will print the sentence “Where are you from” and wait for the user input. Once the user enters the location, it will be sent back to the program. Then we can use a print statement to print
print (input(“Where are you from”))
Variable is the place, where we can store something in memory and retrieve it later in the code
location=input(“Where are you from”)
The above code will get the location from the user and save it in the location variable, this can be used later in the code.
Glad you came this far. Let’s try creating a new brand name generator program
#1. Create a greeting for your program.
print(“Welcome to the Simple Band Name Generator.”)
#2. Ask the user for the country that they grew up in.
country=input(“What’s name of the country you grew up in? \n”)
#3. Ask the user for the name of a pet.
pet=input(“What’s your pet’s name? \n”)
#4. Combine the name of their city and pet and show them their band name.
print(“Your band name could be “+ country +” “+ pet +”\n”)
1 -> Explaining to the user about the program
2 -> Using the input function and variable, We are getting the Country name as an input and storing it in the variable name called “Country”
3-> Again, we are getting the pet name as input and storing it in the variable called pentane
4-> Doing some string concatenation to print the output as needed
As you can see, We have used all the above-discussed concepts in this program. Go ahead and try executing this code in the editor.
Click here for the python editor and try executing the code
Let’s try to do some exercises, Try to edit the code and customize your brand name generator program and share it with us 🙂