SlideServe
Menu
Préférences
© SlideServe · v2026

Python Hello World Program: Basics, Examples & Formatting

feleti avatar
17 diapositives · 294 Views · Sep 15, 2014

Learn how to write a "Hello, World!" program in C, JAVA, and Python. Implement the code in different languages, understand string operations, and practice formatting strings using the print function. Get familiar with Python's interpreter and various methods to run programs.

Python Hello World Program: Basics, Examples & Formatting - slide 1
01 / 17Python Hello World Program: Basics, Examples & Formatting
1 / 17

Télécharger la présentation

Python Hello World Program: Basics, Examples & Formatting
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Lesson 2:Writing a Python Program Computer Science 1 Mr. Bernstein

  2. Hello World Program • Implement by three different languages • In C • In JAVA • In Python

  3. “Hello World” in C main() { printf("hello, world\n"); }

  4. “Hello World” in JAVA class myfirstjavaprog { public static void main(String args[]) { System.out.println("Hello World!"); } }

  5. “Hello World” in Python print (“Hello World!!”)

  6. Python – Interpreter Shell >>> print ("Hello, World! ") Hello, World! >>> "hello" 'hello' >>> "world" 'world' >>> "hello"+"world“ (Concatenation) 'helloworld'

  7. Be familiar with Python >>> "hello" * 3 (Multi string repeat) 'hellohellohello' >>> "hello" * 300

  8. How do you run programs? Three different methods: • 1. Interactive Coding • 2. Files (such as NotePad, WordPad) • 3. Integrated Development Environment (IDE)

  9. Create and run a program in the Python IDLE From File -> New Window Type your program print ("Hello, World! ") Save your program (Give a name you like, such as test.py) Run the program (by selecting the Run Module or pressing the F5 key)

  10. Formatting and Line • \n – moves string to the next line (like hitting the ‘return’ button) • \t - tabs the following string

  11. Examples: Formatting Strings and Lines • Use the print function to write the following in one line: • Money can’t buy me happiness, <return> But I’d rather be crying <tab> in my mansion.

  12. Examples: Formatting Strings and Lines print(“Money can’t buy me happiness,\nBut I’d rather be crying\tin my mansion.”)

  13. End all, BE ALL! Input: print (“Hear no evil,”, end=‘’) print (“ See no evil, Speak no evil.”) Output: Hear no evil, See no evil, Speak no evil.

  14. But Wait! There is more! • What if you want to print the following? I’m just too “cool” for the program!

  15. Error! Bad! print(“I’m just too “cool” for the program!”) Good! print(“I’m just too \“cool\” for the program!”)

  16. Formatting Strings and Lines • \” or \\ allows the print statement to continue, without closing off what is in quotes. Input: print(“Call me, \”maybe\””) Output: Call me, “maybe”

  17. Summary • Simple “Hello World” Program • Creating a Python file/Using Interpreter • Formatting Strings: \t, \n, \(character) • end’’ to keep the same line • Print function: print(“thingtoprint”) • String Operators: * (string multiplier) +(string concatenation)