Giter Site home page Giter Site logo

book1-exercises's Introduction

Course materials for Real Python Course 1: Introduction to Python

book1-exercises's People

Contributors

fheisler avatar michaeljpeake avatar mjhea0 avatar terwebs avatar topleft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

book1-exercises's Issues

Line of code from Fundamental Review does not work

print("four: {}".format()
four[0][5] == 'n' and four[0][0] == "P" and four[2][1] == "u"
)

This gives a syntax error. Changing it to this:

print("four: {}".format(
four[0][5] == 'n' and four[0][0] == "P" and four[2][1] == "u"
))

fixes the issue.

urlopen connection to you test HTTPS URL

I am following you documentation to obtain the Aphrodite web page with the following code:

from urllib.request import urlopen

my_address = "https://realpython.com/practice/aphrodite.html"

html_page = urlopen(my_address)
html_text = html_page.read().decode('utf-8')

print(html_text)

I am getting SSL errors. When I add the cafile option, I get invalid certificate error. How can I makke this work?

11-1.py

Text needs to be encoded by Unicode to write to .txt file ==> pdf_txt.encode("utf-8"). Otherwise I get following error.

Traceback (most recent call last):
File "/Users/xamarind/Documents/pdf_reader.py", line 20, in
output_txt_file.write(pdf_txt)
TypeError: write() argument must be str, not bytes

A bit shorter solution

cats={}
for i in range(1,101):
cats[i]=0

for round in range(1,101): # 100 rounds
for cat in cats: # 100 cats
if cat % round == 0:
cats[cat] = abs(cats[cat]-1) # 1 = hat, 0 = no hat

for i in cats:
if cats[i]==1:
print "Cat with hat: {}".format(i)

13.1py review exercise does not work and code not the same as pdf

Python 3.6.7 (default, Oct 25 2018, 09:16:13)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license()" for more information.

================ RESTART: /mnt/c/projects/realpy/webtest.py ================
Traceback (most recent call last):
File "/mnt/c/projects/realpy/webtest.py", line 7, in
html_page = urlopen(my_address)
File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

update file paths

path = "C:/Real Python/refactor/chp10/practice_files/little pics"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.