Answers for "python script example"

21

how to run a python script

# Save the script in a file with .py extension
# run the script using the below command
python fileName.py
Posted by: Guest on April-23-2020
2

run python.py file

# save a file in text editor with .py
# open terminal, and change directories
# run the following command:
python3 file.py
Posted by: Guest on December-29-2020
0

python script example

# Import the modules
import sys
import random

ans = True

while ans:
    question = raw_input("Ask the magic 8 ball a question: (press enter to quit) ")
    
    answers = random.randint(1,8)
    
    if question == "":
        sys.exit()
    
    elif answers == 1:
        print "It is certain"
    
    elif answers == 2:
        print "Outlook good"
    
    elif answers == 3:
        print "You may rely on it"
    
    elif answers == 4:
        print "Ask again later"
    
    elif answers == 5:
        print "Concentrate and ask again"
    
    elif answers == 6:
        print "Reply hazy, try again"
    
    elif answers == 7:
        print "My reply is no"
    
    elif answers == 8:
        print "My sources say no"
Posted by: Guest on February-01-2021
1

python scripting

import YouTube from pytube
Posted by: Guest on July-05-2021
-2

how to execute a python script

C:\Python27\python.exe C:\Users\Username\Desktop\my_python_script.py
Posted by: Guest on January-29-2021

Browse Popular Code Answers by Language