Setting up or changing working directory in Python

Follow the code.

[python]

# A first Python script
# First set the path to the working directory in Python.
# Specially if you are working with iPython, you can use the magic command %run scriptname.py
#coded by: Ankan Basu
import os
path=’C:\\Users\\Ankan.Basu\\Desktop\\python-programming’
os.chdir(path)
os.getcwd()

import sys
# Load a library module
print(2 ** 100)
print(sys.platform)
# Raise 2 to a power
x = ‘Testing!’
print(x * 8)
# String repetition
# To run use: %run script1.py

[/python]

Output

%run script1.py
win32
1267650600228229401496703205376
testing!testing!testing!testing!testing!testing!testing!testing!

Leave a Comment

Your email address will not be published. Required fields are marked *