This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android | |
import time | |
droid = android.Android() | |
debug = False | |
def getBatteryEvents(): | |
droid.batteryStartMonitoring() | |
droid.eventWaitFor("battery") | |
droid.batteryStopMonitoring() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#_*_ coding: utf-8 _*_ | |
#Code (C) Janne Salokoski 2014 | |
import math | |
def muuttuja(): | |
#Tehtävä 2.1 | |
print("|--------Tehtävä 2.1--------|") | |
print("| Muuttuja |") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date | |
kuukaudet = ["tammi", | |
"helmi", | |
"maalis", | |
"huhti", | |
"touko", | |
"kesä", | |
"heinä", | |
"elo", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# _*_ coding: utf-8 _*_ | |
### | |
# Copyright (c) 2014, Janne Salokoski | |
# All rights reserved. | |
### | |
""" | |
Performs all the tasks for the AT04 course |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start(self, name): | |
length = len(name) | |
wordLength = length | |
print("\n") | |
if length > 20: | |
length = length + 2 | |
print("|", end="") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def multiplicationTable(n): | |
# Is readable and the ouput looks good. | |
y = 1; result = "" | |
for i in range(1, n + 1): | |
x = 1 | |
for j in range(1, n + 1): | |
result += "{:3}".format(x * y) | |
x += 1 | |
result = result + "\n" | |
y += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# _*_ coding: utf-8 _*_ | |
### | |
# Copyright (c) 2014, Janne Salokoski | |
# All rights reserved. | |
### | |
""" | |
Performs all the tasks for the AT04 course |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start(name, prompt = True): | |
"""Prints out a nice ASCII box for the name of the task""" | |
if prompt == True: | |
input("\nJatka painamalle 'enter'.\n") | |
center = "| {:^16} |".format(name) | |
side = ("|{:-^" + str(len(center) - 2) + "}|").format("-") | |
box = side + "\n" + center + "\n" + side | |
print(box) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
palindroms = [] | |
fileName = str(input("Anna luettavan tiedoston nimi: ")) | |
f = open(fileName, "r+") | |
for line in f: | |
for word in line.split(): | |
if word == word[::-1]: | |
palindroms.append(word) | |
f.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# _*_ coding: utf-8 _*_ | |
### | |
# Copyright (c) 2014, Janne Salokoski | |
# All rights reserved. | |
### | |
""" | |
Performs all the tasks for the AT04 course |