DEV Community

Ghazal Abdulraheem
Ghazal Abdulraheem

Posted on

Build a Band Generator

In this post, you'll learn how to build a fun project called "Band Name Generator." But before that, I’d like to explain some fundamental concepts used in building the project.

I started the amazing #100DaysOfCode challenge today, and I picked up Python Crash Course by Angela Yu to unlearn, relearn, and refresh my Python skills as a developer.

Python is a fun programming language to learn, especially if you're just starting out as a developer. It has an easy-to-read syntax and allows you to build real-world relatable projects while learning.

Here are some of the things I learned on Day 1:

String Manipulation

Python gives us the flexibility to manipulate strings. You might ask, what is a string?

A string is a collection of characters arranged together in a linear format. Examples include:

  • "Great"
  • "linux123"
  • "Hello World!"

Error Types

As a Python developer, understanding the types of errors you encounter will help you ask the right questions when searching for solutions.

Here are some basic error types I learned on Day 1:

1. IndentationError

This error occurs when indentation is used incorrectly in your code.

Example:

```python id="i8l5n1"
print("Hello")




Python relies heavily on proper indentation, especially inside functions, loops, and conditionals.

---

### 2. SyntaxError

This error occurs when you do not follow the correct syntax of the language.

Example:



```python id="g42bh3"
print("Hello)
Enter fullscreen mode Exit fullscreen mode

Correct version:

```python id="5bj62q"
print("Hello")




The first example is missing the closing quotation mark.

---

### 3. NameError

This error occurs when you reference a variable name that has not been declared.

Example:



```python id="6h0t5r"
name = "Richard"
print(nama)
Enter fullscreen mode Exit fullscreen mode

The code above will result in a NameError because nama was never defined.


4. TypeError

This error occurs when you try to perform an operation between incompatible data types.

Example:

```python id="5d5e8x"
data = "Skyscrappers"
print("We currently have " + len("three") + data)




This will result in a `TypeError` because `len("three")` returns a number, and Python cannot concatenate a string with an integer directly.

Correct version:



```python id="9l2qj8"
data = "Skyscrappers"
print("We currently have " + str(len("three")) + " " + data)
Enter fullscreen mode Exit fullscreen mode

The str() function converts the number into a string, allowing Python to process the concatenation correctly.


Variables

A variable is a storage container used to hold data for future use.

Example:

```python id="bx38d4"
taxID = 1234567890




---

## **len()**

The `len()` function helps us count the number of characters in a string.

Example:



```python id="wb06dc"
len("Hello")
Enter fullscreen mode Exit fullscreen mode

input()

The input() function allows us to collect data from users for further processing.

Example:

```python id="2jlwmn"
input("What is your name?")




---

## **str()**

The `str()` function converts other data types into strings.

Example:



```python id="3b7e1u"
str(4)
Enter fullscreen mode Exit fullscreen mode

print()

The print() function is one of the most commonly used functions in Python. It displays output in the terminal.

Example:

```python id="q9m4t0"
print("Can I come now?")




---

Now that you understand the basics, let’s build our Band Name Generator app.

# Band Name Generator



```python id="yojv2n"
# Declare variables to store city and pet name

city = input("Which city did you grow up in?\n")

petName = input("What is your favorite pet's name?\n")

# Display the final band name using concatenation
print("Yup! Your band name is " + city + " " + petName)
Enter fullscreen mode Exit fullscreen mode

If you found this interesting, share your thoughts in the comment section.

Top comments (0)