Log in to StudySoup
Get Full Access to AU - Study Guide - Final
Join StudySoup for FREE
Get Full Access to AU - Study Guide - Final

Already have an account? Login here
Reset your password

AU / Business Analytics / BUAL 5650 / What are the phyton variable name rules?

What are the phyton variable name rules?

What are the phyton variable name rules?


School: Auburn University
Department: Business Analytics
Course: Big Data I
Professor: Nasrin mohabbati
Term: Fall 2018
Cost: 50
Name: BUAL 5650 - Final Study Guide
Description: Python and all you need to know about it
Uploaded: 11/30/2018
13 Pages 90 Views 2 Unlocks

crotroman5683 (Rating: )


What are the phyton variable name rules?

integers, Boolean, float, string whole, T/F, decimal, anything in ‘’ or “” MUST DEFINE VARIABLES

type(variable) - tells type

int() - change variable to whole number float() - change variable to decimal Follows order of operations

 —— (), **, */, +- ——

**exponent %remainder //rounded ! =does not equal +=/-=/*=increment by print() - displays whatever in is the () ’variable’ in structure - see if exists in  list/tuple/set (T/F returned)

variable.action or action(variable) indexing starts with 0

What is the function of phyton?

We also discuss several other topics like How do we have social control?


if:/elif:/else: - case sensitive


define with [ ], separate entries with ,

a=[1, 2, 3, 4]

a[0] - tells firsts entry of list

a[1:9:3] - slices starting at the first entry and going to the  9th (but not incl 9th) , every third entry (1, 3, 6)

len() - counts the length We also discuss several other topics like Poverty is caused by what?

min()/max() - shows 1st/last or low/high

[ ] + [ ] - concatenates lists

What are the different classes of objects?

name.append() - adds to list

name.index(index_value) - shows first list entry at value name.count() - counts the entries in the list

name.insert() - adds to list; use (x,y) for replacing a spec  location, name.insert(4,300) replaces 4 spot with 300 name.pop() - prints value then removes from list

name.reverse() - reverses the order of the list

name.remove(’entry’) - removes the specified entry name.sort() - sorts in ascending order; also (key=len) name.split() - splits list at designated marker If you want to learn more check out Who is the chairman of foreign relations committee?

name.extend([newlist]) - adds list by newlist

del name[index_value] - removes item at index value for counter in range() loop - case sensitive  We also discuss several other topics like What is the basic idea of natural selection?


define with ( ), separate entries with ,


C=(a, b, c)

new_list = sorted(tuple_name) - sorts tuple into a new  list


define with { }, separate entries with ,

‘key': paired value —> no indexing

key should be a string and unique

D={‘key1’:value1, ‘key2’:value2,etc}

dict.items() - Outputs all values in dictionary x=dict.keys() 

y=dict.values() – creates a dictionary with two separate  lists (x & y) Don't forget about the age old question of What makes demand more price elastic?

d=dic(zip(x,y)) - creates new dictionary (d) from the two  lists

del(d[’key1’]) - deletes ‘key1’ from dictionary (d) CAN dict.pop(value) same as with list


define with { }, separate entries with ,

indexing is difficult, adds don’t occur in default position CANNOT DUPLICATE VALUES

S1={‘a’, 2, ‘3’, 3} S2={‘b’, 6, ‘3’, 4}

S1 & S2 - shows values in BOTH sets; intersection S1.union(S2) - adds both sets into one; no duplicates

starts at the beginning of the line unless nested action is indented

runs action only if statement is TRUE

runs through each line until the end of code can simultaneously check two conditions with and and or


counter can be ANY variable - defined because it’s a for loop If you want to learn more check out Explain the function of a ticketron.

action is indented

runs through each line until the range is met

used when you know the beginning and end of the loop

if word then parameter or operation

if word then variable

if word then python command

if word then function



if x<y: 

 print('x is less than y') 

elif x >y: 

 print ('x is greater than y') 


 print ('x is equal to y') 

Output: ‘x is greater than y’

for i in range(10,80): 

 if i%3 == 0: 


Output: all factors of 3

inputData = [1,5,2,4,0,8,3,0,9,7,10]

def sortNumbers(data): 


 return data


Output: [0, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10]

def Square(a): 



Output: 25

Class SoftwareEngineer(): 

 def _init_(self, name, age): 

self.name = name

self.age = age

 def _init_(self, value): 

self.money = value

print (self.name,”earns”,self.money) 

a = SoftwareEngineer('Kartik',26) 


Output: Kartik earns 40000

def printHelloWorld(printCount): 

 for i in range(printCount): 

 print ('Hello World!') 

 return None 

numberTimesToPrint = 3


Output: ‘Hello World!’ 3 times

def factorial(num): 

 f = 1

 for i in range(0,num): 

 f *= (i+1)


print (factorial(1), factorial(2),factorial(3),factorial(4), factorial(5)) Output: 1 2 6 24 120

for i in range(10): 


Output: all numbers 0-9

count = 0

for i in range(4): 

 count += 2


Output: 2 4 6 8

count = 0

for i in range(1,5): 



 count += 1

 print(/n)<—puts each on new line Output: 1 0 (line break)2 1 (lb) 3 2 (lb)4 3

a = [1, 2, 3, 3]

b = [4, 5, 6]

c = [7, 8, 9]

master_list = [a, b, c]

for l in master_list: #for every list

 forj inl: #look at every entry in the list  print (j) #print entries in list

 #for every entry in the list, print the entry Output: 1 2 3 3 4 5 6 7 8 9

num = 1

factors = []

while num < 100: 

 num *= 3 #num = num*3

 print (num) 



Output: 3 6 9 27 81 243 [3, 9, 27, 81, 243]

num = 1

while num < 100: 

 num = num*2

 if num == 64: 

 print ('64: continue') #or add break to stop  pass #continue or add break to stop  print (num) 

print ('Done!') 

Output: 2 4 6 8 16 32 64: continue 64 128 Done! ***can also break/break***

Page Expired
It looks like your free minutes have expired! Lucky for you we have all the content you need, just sign up here