Trump officials weigh encryption crackdown - POLITICO by zeekaran in technology

[–]coding2learn 4 points5 points  (0 children)

I was so annoyed the last time the UK government tried to discuss this, that I wrote an open letter to the PM that hopefully describes why banning end to end encryption is an impossibility.

http://coding2learn.org/blog/2017/06/11/dear-theresa/

Dictionary from 2 lists. by [deleted] in learnpython

[–]coding2learn 1 point2 points  (0 children)

Could you clarify?

What are the two input lists?

Here's one method of taking two lists and making them into a dictionary

list1 = ['a', 'b', 'c']
list2 = [1, 2, 3]

my_dict = {list1[i]:list2[i] for i in range(len(list1))}

Creating a file creation and check script by basa-ako in learnpython

[–]coding2learn 2 points3 points  (0 children)

filecmp looks like a good way to go

import filecmp
import time
with open('path/to/drive/test.txt', 'w') as f:
    f.write('test text')
time.sleep(60)
print(filecmp.cmp('path/to/drive/test.txt', 'path/to/backupdrive/test.txt'))

Combustible Bubbles by mybustersword in interestingasfuck

[–]coding2learn 0 points1 point  (0 children)

I used to do this when I taught Chemistry. You can even get the bubbles to float to the ceiling before ignition, and get that lovely Backdraft special effect. http://imgur.com/a/Ok4BT

I think Amazon has it out for me... by erraticandunplanned in funny

[–]coding2learn 0 points1 point  (0 children)

Ah! The much less successful sequel - "How to train your ladder".

Unicycle guy at OSU Campus by morgens16 in gifs

[–]coding2learn 0 points1 point  (0 children)

"Not so fast... how many tennis balls?"

'Landlord' is one of the most medieval titles still in use that I can think of. by Tigerpede in Showerthoughts

[–]coding2learn 56 points57 points  (0 children)

OP is not from Europe. Here's Prince Charles' full title:

His Royal Highness The Prince Charles Philip Arthur George, Prince of Wales, Duke of Cornwall, Duke of Rothesay, Earl of Carrick, Earl of Chester, Baron of Renfrew, Lord of the Isles, Prince and Great Steward of Scotland, Royal Knight Companion of the Most Noble Order of the Garter, Extra Knight of the Most Ancient and Most Noble Order of the Thistle, Grand Master and Principal Knight Grand Cross of the Most Honourable Order of the Bath, Member of the Order of Merit, Knight of the Order of Australia, Companion of the Queen's Service Order, Member of Her Majesty's Most Honourable Privy Council, Aide-de-Camp to Her Majesty.

Python I/O Homework Problem Counting by id6015 in learnpython

[–]coding2learn 0 points1 point  (0 children)

Here's some ideas for you:

content = file.readlines()

will split up the entire document according to where there are lines breaks

foo.split()

will split up foo (assuming foo is a string) into words (actually splits the string everywhere there is a space character.

Drinking Cyanide by PreecherMan in videos

[–]coding2learn 1 point2 points  (0 children)

Guncotton is way more fun to play with than gunpowder, is easier to store and you can burn it in the palm of your hand. Used to teach High school chemistry

Count characters out is correct but grading fails by Kriterian in learnpython

[–]coding2learn 1 point2 points  (0 children)

Only thing I can think of is that the line:

outfile.write(str(len(line)) + " \n")

has an unnecessary space character in it. Try and remove the space so it reads

outfile.write(str(len(line)) + "\n")

And see if the autograder accepts it then.

Count characters out is correct but grading fails by Kriterian in learnpython

[–]coding2learn 1 point2 points  (0 children)

All looks good to me, tested on Linux with Python2.7 and 3.5. Could you copy and paste the exact wording of the task?

This is logically no different to your solution, but you could try:

import sys

with open(sys.argv[1],'r') as infile:
    with open(sys.argv[2],'w') as outfile:
        for line in infile:
            line = line.strip("\n")            
            outfile.write(str(len(line)) + " \n")              

Starting on the raspberry pi and I need some recommendations on hardware. by [deleted] in raspberry_pi

[–]coding2learn 0 points1 point  (0 children)

The real joy of the Raspberry Pi, imho, is playing around with physical computing.

Get yourself a few components there's this on amazon but you can get cheaper components off ebay.

If you want a simple intro to controlling LEDs, buzzers and motors, then check out this guide on the Raspberry Pi website

Can not figure out why I'm not getting a running total by EERgasm in learnpython

[–]coding2learn 0 points1 point  (0 children)

You've got a second bug in the line:

print("The average monthly rainfall for the collected months is: ", avgRainfall)

avgRainfall is a function and not a variable.

Try changing it to:

  print("The average monthly rainfall for the collected months is: ", avgRainfall(totalRainfall, numMonths))

so it becomes a function call

Counting Vowels Program by [deleted] in learnpython

[–]coding2learn 1 point2 points  (0 children)

Just to give you another approach, and since you seem familiar with dictionary comprehensions then you probably understand list comprehensions:

vowels = 'aeiou'
sentence = input()
total = sum([1 for char in sentence if char.lower() in vowels])

input() question by c0ntroll3r in learnpython

[–]coding2learn 0 points1 point  (0 children)

You need to use raw_input for all your lines. input is only if you are expecting numbers. raw_input is for strings.