My First Python Script: Hello, Strings & Print!

Today, I completed my very first Python script assignment! The goal was simple: run a basic script using the print() function and a string variable. Although it felt basic, especially coming from R programming, it allowed me to explore PyCharm, understand how files work, and become comfortable running code.

Here’s the assignment code:

# First line: simple print statement
print("Hello, world!")
# Second: create a string with single quotes and print it
String1 = 'Welcome to the Geeks World'
print("String with the use of Single Quotes:")
print(String1)

🔍 Why This Works

The print() function and string data types in Python work together because the function is specifically designed to accept string input and display it as output. A string in Python is a sequence of characters enclosed in either single or double quotes. When passed into the print()function, the string is evaluated and printed to the screen as-is, making it ideal for communicating messages to users or displaying variable values. For example, both print(“Hello, world!”) and print(‘Hello, world!’) function identically and produce readable text.

However, the interaction between print and string can fail if the syntax is incorrect or if an undefined variable is referenced. For example, writing print(‘Hello) without a closing quote results in a syntax error, while using print(Hello) without first defining message will raise a NameError. These issues are not due to incompatibility between the two, but rather to user mistakes in syntax or logic that Python cannot interpret.

My Experience with PyCharm

Coming from an RStudio background, coding using PyCharm felt very different. PyCharm is more structured and robust, but it can also be a bit intimidating at first. That said, I’m happy this first assignment was small and very basic. It helped me get accustomed to the environment, locate the console, set up my project directory, understand how files are saved, and begin thinking like a Python developer.

Python might be powerful or intimidating, but today it felt like it wasn’t so bad after all! 😊

References

Leave a comment