C
C
canabisss2018-09-19 18:40:04
Python
canabisss, 2018-09-19 18:40:04

How to count weekdays?

Training practice for students of the specialty "Information systems in management" in DonSTU starts on the k-th of June and lasts for 3 weeks. Entrance exams in DonSTU begin on July 1. How many days of study practice in a given year coincide with the entrance exams (consider working days only)?
It is necessary to build a flowchart for this task, how to calculate weekdays

k = int(input("Число: "))
g = int(input("Год: "))
i = 0
l = 21 											# счетчик недель практики
f = 31 - k                   					# оставшиеся кол-во дней до конца месяца
if k >=10:
        print("Дней практики в июле: " + str(l - f))
        a = 0 #(14 - 6)/12
        y = g - a
        m = 12 #6+12*a-2
       dnd = ((1 + y + y // 4 - y // 100 + y // 400 + (31* 7+12 * 0 - 2)) % 7) # 1 июля 
        print(str(dnd) + " день недели")
        while dnd != 0 or l == 0 or dnd != 6:
            i += 1              # счетчик дней
            if dnd >= 5:
                dnd = 0
                l = l - 2
            else:
                dnd += 1
                l = l - 1
        r = (l / 7) * 5
        v = (l - r) - 1
        i = i + r + v
        print("Совпадающих дней: " + str(i))

else:
  print("Общих дней нет")


a = (14 − месяц) / 12   # 0
y = год − a			  # y
m = месяц + 12 * a − 2   # 7+ 12 * 0 - 2
ДеньНедели = (день + y + y / 4 − y / 100 + y / 400 + (31 * m) / 12) ОСТАТОК 7
y = int(input())

I wrote an algorithm for myself in python. because I know him a little
, but I still can't think of the problem. This is a task from the training manual at the university, we will write in c ++

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-09-19
@dimonchik2013

start = date(2018, 7, 1)  
end = date(2018, 9, 15)  
all_days = [start + timedelta(x) for x in range((end - start).days + 1)]
week_days = [x for x in all_days if x.weekday() in [1, 2, 3, 4, 5]]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question