Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions 33 lab-01/file_ops.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
#!/usr/bin/python


# Open the license file, read the content into the buffer
# then close the file descriptor

f = open('conditions.py')
lines10 = f.read(10)
#alllines = f.read()
print (lines10)
f.close()
# f = open('conditions.py')
# lines10 = f.read(10)
# # #alllines = f.read()
# print (lines10)
# f.close()

# Open the license file, read the content as "lines" into the
# buffer and close it.

f = open('conditions.py')
file_content = f.readlines()
f.close()
print file_content
f.close()

for line in file_content:
#print line.split()
if len(line) !=0:
line_list = line.split()
if len(line_list) !=0:
if line_list[0] == 'print':
print line_list

# READ 15-20
# f = open('conditions.py')
# f.seek(15)
# line15 = f.read(5)

# TRYING READ VS READLINES
# f = open('conditions.py')
# file_content = f.read()
# print file_content
# f.close()
25 changes: 18 additions & 7 deletions 25 lab-01/list-operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@

new_list = []

for l in mylist:
#print l * 100
new_list.append(l + 100)
for list_item in mylist:
new_item = list_item * 100
#add_more = new_item +50
new_list.append(new_item)
#new_list.append(add_more)
# print new_list
# print max(new_list)
# print min(new_list)
# print sum(new_list)

print new_list
print max(new_list)
print min(new_list)
print sum(new_list)
# for l in mylist:
# #print l * 100
# new_list.append(l + 100)

# 2-10, put in a list
this_list = []
for item in (range (2,10)):
#add10 = item + 10
this_list.append(item)
print this_list
17 changes: 17 additions & 0 deletions 17 lab-02/Ex0910b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import multiprocessing

import os

def myfunction():
print multiprocessing.cpu_count()
#print os.cpu_count
#kernel name
print os.uname()[0]
# load average
print os.getloadavg
#uptime
print os.system("uptime")
#disk usage
print os.system("df -h")

print myfunction()
18 changes: 18 additions & 0 deletions 18 lab-02/exercise0910.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def myfunction(filename, num_lines):
#return error if the filename is less than 4 - length
if len(filename) > 4:
#copies arg2 number of lines of arg1 into home dir
f = open(filename)
f2 = f.read(filename)
home_dir_file = []
home_dir_file = f2.split("\n")
print home_dir_file
#to slice to number of line - use colon
#n = int(num_lines)
print_this = home_dir_file[:num_lines]
for each in print_this:
print each

# ~/devopstraining/ansible/
myfunction("/Users/localadmin/devopstraining/ansible/mylogfile.log", 3)
print "error"
7 changes: 7 additions & 0 deletions 7 lab-02/func-03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def myfunction(arg1, arg2):
#multiply
answer = arg1 * arg2
#return arg1 * arg2
#print
print answer
myfunction(1,2)
7 changes: 6 additions & 1 deletion 7 lab-02/functions-args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
def myfunction(arg1, arg2,arg3):
print "My Very first python function with Arguments"
print "{},{},{}".format(arg1, arg2, arg3)
sum = arg1 + arg2 + arg3

#return sum

if arg3 == "chicago":
second_func(arg1,arg2)
Expand All @@ -21,4 +24,6 @@ def third_func(arg1):


if __name__ == "__main__":
myfunction("hello","world","chicago")
# myfunction(1,2,3)
myreturn = myfunction(1,2,3)
print my_return
22 changes: 22 additions & 0 deletions 22 lab-06/E0910b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import requests

def count_yelp(text):
all_words = text.split()
yelp_count = all_words.count('Yelp')
return yelp_count

def replace_yelp(text):
return text.replace('yelp','google')

r = requests.get('http://wwww.yelp.com')
if r.status_code == 200:
# print r.content
print count_yelp(r.text)
#print replace_yelp(r.text)

# Assignment

# Load the yelp page and replace all occurance of yelp to google

# Load the file from http://censusdata.ire.org/36/all_050_in_36.P2.csv and find
# the max P002001
Morty Proxy This is a proxified and sanitized view of the page, visit original site.