1. Taking spaced input
x = raw_input().split() ## x is a list print x
2. Taking the integer spaced input
x = map(int , raw_input().split()) print x
3. Moving a directory upwards, shell command equivalent ‘cd ..’
import os os.getcwd() ## prints the current working directory up_path = os.path.split( os.getcwd() )[-2] os.chdir( up_path ) os.getcwd() ## you will be moved one directory upwards
4. Capitalizing the first letter in every word in a sentence: Split the sentence with white-space as delimiter which returns a list. Here it returns [this, is, wordpress]. Now for each word in the list, capitalized and joined with white space delimiter.
import string sentence = "this is wordpress" print ' '.join([string.capitalize(word) for word in sentence.split(' ')])