on 7c41bd7 help sign in
100 lines 13 kB history raw
1from os import getcwd
2import numpy as np
3from matplotlib.pyplot import plot as plt
4from time import *
7# COMMENT test
8h2 = 4 # this is a comment
9"""this is also a comment"""
11# Import test
13# class test
16class Hello:
17 def __init__(self, x):
18 self.name = x
19 
20 def selfprint(self):
21 print("hello my name is ", self.name)
23 def testprint(self):
24 print(1*2, 2+3, 4 % 5, 8-4, 9/4, 23//4)
26# Decorators test
27class Decorators:
28 @classmethod
29 def decoratorsTest(self):
30 pass
31 
32H1 = Hello("john")
33H1.selfprint()
34H1.testprint()
37# list test
38a = [1, 2, 3, 4, 5]
39a.sort()
40print(a[1:3])
41print(a[:4])
42print(a[2])
43print(a[2:])
45# dictionary test
46# copied from w3schools example
48myfamily = {
49 "child1": {
50 "name": "Emil",
51 "year": 2004
52 },
53 "child2": {
54 "name": "Tobias",
55 "year": 2007
56 },
57 "child3": {
58 "name": "Linus",
59 "year": 2011
60 }
61}
63# tuple test
65testTuple = ("one", 2, "3")
66print(testTuple)
68print(np.random.randint(5, 45))
70# string test
71a = "hello world"
72b = """good morning
73hello world
74bye"""
76formattest = "teststring is ={}".format(5)
78# lambda test
81def x2(n):
82 lambda n: n/7
85# if else ladder
86if 1 > 2:
87 print("yes")
88elif 4 > 5:
89 print("maybe")
90else:
91 print("no")
93# loops
94i = 5
95while(i > 0):
96 print(i)
97 i -= 1
99for x in range(1, 20, 2):
100 print(x)