-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path1-podstawy.py
126 lines (77 loc) · 2.36 KB
/
1-podstawy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- coding: utf-8 -*-
''' OGÓLNY POGLĄD NA SYNTAX '''
print("Witamy w Pythonie!")
num_var = 5
limit_var = 10
def first_function():
print("Iteracja po " + str(limit_var) + " liczbach") # komentarz!
for x in range(limit_var):
if x == num_var:
print("x równe {}".format(x))
else:
print("")
''' DEFINICJE FUNKCJI'''
def print_word(word):
print(word)
def print_args(*args):
for index, value in enumerate(args):
print('{0}. {1}'.format(index, value))
print_args('apple', 'banana', 'carrot')
def print_kwargs(**kwargs):
for name, value in kwargs.items():
print('{0} is {1}'.format(name, value))
print_kwargs(fruit='apple', vegetable='carrot')
def print_default_value(fruit, vegetable='carrot', **kwargs):
print('Fruit is {}'.format(fruit))
print('Vegetable is {}'.format(vegetable))
for name, value in kwargs.items():
print('{0} is {1}'.format(name, value))
print_default_value('apple')
# or
print_default_value(fruit='apple')
print_default_value('apple', 'carrot', meat='bacon')
# or
print_default_value('apple', meat='bacon')
''' IMPORTOWANIE'''
import math
import sys
from django.forms import *
import our_application.module
'''CZESTE OPERACJE NA TYPACH DANYCH'''
# program losuje zbiór 6 unikatowych liczb od 1 do 49
from random import choice
results = set()
while len(results) < 6:
results.add(choice(range(1,50)))
for x in results:
print(x)
# przykład iteracji po słownikach
dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
for val in dishes.values():
print(val)
for key in dishes.keys():
print(key)
for key, val in dishes.items():
print(key, val)
# Lista Ocen Studentów przy wykorzystaniu klas
class Student:
name = ""
surname = ""
mark = 0.0
students = []
print('Podanie pustej wartosci konczy wpisywanie')
while True:
surname = input('Podaj nazwisko studenta > ')
name = input('Podaj imie studenta > ')
mark = input('Podaj ocene studenta > ')
if not(surname and name and mark):
break
student = Student()
student.surname = surname
student.name = name
student.mark = float(mark)
students.append(student)
for idx, student in enumerate(students):
print('{}. {} {} {}'.format(idx+1, student.surname, student.name, student.mark))
# DEBUGOWANIE
import pdb; pdb.set_trace()