Course materials for Real Python Course 1: Introduction to Python
realpython / book1-exercises Goto Github PK
View Code? Open in Web Editor NEWBook 1 -- Exercises for the book
Book 1 -- Exercises for the book
Course materials for Real Python Course 1: Introduction to Python
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.
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?
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
cats = [False] * (100 + 1) it creates 101 number of cats when we need only 100 by the description.
>>> len([False] * (100 + 1))
101
You have 100 cats.
Does anybody have chapter 6?
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)
Found it
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
They seem to have been omitted.
path = "C:/Real Python/refactor/chp10/practice_files/little pics"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.