on 2e98519 help sign in
95 lines 12 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 testt
13# class test
16class Hello:
17 def __init__(self, x):
18 self.name = x
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)
27H1 = Hello("john")
28H1.selfprint()
29H1.testprint()
32# list test
33a = [1, 2, 3, 4, 5]
34a.sort()
35print(a[1:3])
36print(a[:4])
37print(a[2])
38print(a[2:])
40# dictioary test
41# copied from w3school example
43myfamily = {
44 "child1": {
45 "name": "Emil",
46 "year": 2004
47 },
48 "child2": {
49 "name": "Tobias",
50 "year": 2007
51 },
52 "child3": {
53 "name": "Linus",
54 "year": 2011
55 }
56}
58# touple test
60testTuple = ("one", 2, "3")
61print(testTuple)
63print(np.random.randint(5, 45))
65# string test
66a = "hello world"
67b = """good morning
68hello world
69bye"""
71formattest = "teststring is ={}".format(5)
73# lamda test
76def x2(n):
77 lambda n: n/7
80# if else ladder
81if 1 > 2:
82 print("yes")
83elif 4 > 5:
84 print("maybe")
85else:
86 print("no")
88# loops
89i = 5
90while(i > 0):
91 print(i)
92 i -= 1
94for x in range(1, 20, 2):
95 print(x)