Using Python


  1. Check the Python Help Pages.

  2. Apply for a UND Engineering Linux Account.

  3. Use VPN (Virtual Private Network) to connect to the UND networks.
  4. You may not need to do this if you are on campus.

  5. Log in to the Linux server undcemcs02.und.edu .

  6. Create a Python script such as HelloWorld.py:

  7. # A program that greets the user and performs a simple calculation
    
    # Step 1: Greet the user
    print( "Hello, welcome to the Python program!" )
    
    # Step 2: Ask for the user's name
    name = input( "What's your name? " )
    
    # Step 3: Personalize the greeting
    print( f"Nice to meet you, {name}!" )
    
    # Step 4: Perform a simple calculation
    print( "Let's do a quick math calculation." )
    num1 = float( input( "Enter the first number: " ) )
    num2 = float( input( "Enter the second number: " ) )
    
    # Step 5: Add the numbers and display the result
    result = num1 + num2
    print( f"The sum of {num1} and {num2} is {result}." )
    
    # Step 6: Say goodbye
    print( f"Thanks for trying this program, {name}! Have a great day!" )

  8. Compile and run the script.
  9. For example,
        shell⯈ /usr/bin/python  HelloWorld.py 
    
        Hello, welcome to the Python program!
        What's your name?  Poke Mon 
        Nice to meet you, Poke Mon!
        Let's do a quick math calculation.
        Enter the first number:  5 
        Enter the second number:  7 
        The sum of 5.0 and 7.0 is 12.0.
        Thanks for trying this program, Poke Mon! Have a great day!