Loading...
More Python Posts
# importing the modulesimport osimport shutil# getting the current working directorysrc_dir = os.getcwd()# printing current directoryprint(src_dir)# copying the filesshutil.copyfile('test.txt', 'test.txt.copy2') #copy src to dst# printing the list of new filesprint(os.listdir())
#Loop back to this point once code finishesloop = 1while (loop < 10):#All the questions that the program asks the usernoun = input("Choose a noun: ")p_noun = input("Choose a plural noun: ")noun2 = input("Choose a noun: ")place = input("Name a place: ")adjective = input("Choose an adjective (Describing word): ")noun3 = input("Choose a noun: ")#Displays the story based on the users inputprint ("------------------------------------------")print ("Be kind to your",noun,"- footed", p_noun)print ("For a duck may be somebody's", noun2,",")print ("Be kind to your",p_noun,"in",place)print ("Where the weather is always",adjective,".")print ()print ("You may think that is this the",noun3,",")print ("Well it is.")print ("------------------------------------------")#Loop back to "loop = 1"loop = loop + 1
list_1 = [1,2,3,4,5,6,7,8,9]cubed = map(lambda x: pow(x,3), list_1)print(list(cubed))#Results#[1, 8, 27, 64, 125, 216, 343, 512, 729]
print('hello, world')
def print_pyramid_pattern(n):# outer loop to handle number of rows# n in this casefor i in range(0, n):# inner loop to handle number of columns# values changing acc. to outer loopfor j in range(0, i+1):# printing starsprint("* ",end="")# ending line after each rowprint("\r")print_pyramid_pattern(10)
def calculate_values():value1 = 10value2 = 20return value1, value2result1, result2 = calculate_values()print("Result 1:", result1)print("Result 2:", result2)