Run a for loop for each item in a list for variable in list_name: print variable Run a for loop for each item in a dictionary webster = { "Aardvark" : "A star of a popular children's cartoon show.", "...Read More
Lists Creating a list list_name = ["item1", "item2", "item3"]; Call the 3rd item in the list print "The first item is: " + list_name[2] Replace item3 in the list list_name[2] = "New_Value" Append item...Read More
Find the largest number in a set maximum = max(-5, 10, 600, 53, 55554.43) print maximum Find the smallest number in a set minimum = min(3, 5, 6) print minimum Find the absolute value of a number absol...Read More
Functions are defined with three components: 1. The header, which includes the def keyword, the name of the function, and any parameters the function requires. Here’s an example: def hello_world...Read More
Input Ask the user for their input and place into Var1 Var1 = raw_input("What variable do you want to set the variable to?" Verify that the input is not empty original = raw_input("Enter a word: ") if...Read More
Comparators Comparators work with booleans to define a variable as either ‘True’ or ‘False’. For example: Var1 = 5 == 5 Var2 = 10 < 5 print(Var1) print(Var2) True False Comp...Read More
Date Time Library Import the library import datetime Print the full date now = datetime.now() print(now) Print the year, month, day, hour, minute, or second now = datetime.now() print(no...Read More
Variables Number/Float my_variable = 10 Boolean my_bool = True Function def test(): var1 = 10 return var1 Strings name = "Nikko" Print Print the output of a function print function...Read More