반응형
반응형

 

https://github.com/MauryaRitesh/Facial-Expression-Detection

 

GitHub - MauryaRitesh/Facial-Expression-Detection: Facial Expression or Facial Emotion Detector can be used to know whether a pe

Facial Expression or Facial Emotion Detector can be used to know whether a person is sad, happy, angry and so on only through his/her face. This Repository can be used to carry out such a task. - G...

github.com

Facial Expression or Facial Emotion Detector can be used to know whether a person is sad, happy, angry and so on only through his/her face. This Repository can be used to carry out such a task.

This is the code for this video by Ritesh on YouTube.

Facial Expression or Facial Emotion Detector can be used to know whether a person is sad, happy, angry and so on only through his/her face. This Repository can be used to carry out such a task. It uses your WebCamera and then identifies your expression in Real Time. Yeah in real-time!

PLAN
This is a three step process. In the first, we load the XML file for detecting the presence of faces and then we retrain our network with our image on five diffrent categories. After that, we import the label_image.py program from the last video and set up everything in realtime.

반응형
반응형

Python Dictionary Methods

 https://www.instagram.com/p/CrKgbEGrrX_/?igshid=MDJmNzVkMjY%3D 

Clear()

Copy()

Get()

Items()

Keys()

Popitem()

Values()

Pop()

Update()

Setdefault()

 

 

Method Description

clear() Removes all the elements from the dictionary
copy() Returns a copy of the dictionary
fromkeys() Returns a dictionary with the specified keys and value
get() Returns the value of the specified key
items() Returns a list containing a tuple for each key value pair
keys() Returns a list containing the dictionary's keys
pop() Removes the element with the specified key
popitem() Removes the last inserted key-value pair
setdefault() Returns the value of the specified key. If the key does not exist: insert the key, with the specified value
update() Updates the dictionary with the specified key-value pairs
values() Returns a list of all the values in the dictionary

https://www.w3schools.com/python/python_ref_dictionary.asp

 

Python Dictionary Methods

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

https://www.w3schools.com/python/python_dictionaries.asp

 

Python Dictionaries

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

반응형
반응형

[python]  swapping variables, Flattening a list of lists

# Swapping variables without a temporary variable

a = 10
b = 20
a,b = b,a

print(a)

# Flattening a list of lists

lst = [[1,2,3],[4,5],[6,7,8,9]]

flattened = [num for sublist in lst 
             for num in sublist]

print(flattened)
반응형
반응형

Python Script to Shutdown Computer

 

컴퓨터를 종료하는 Python 스크립트

Python은 다양한 기능으로 인해 널리 사용되는 스크립팅 언어입니다. 이 기사에서는 컴퓨터를 종료하는 Python 스크립트를 작성합니다. Python 스크립트를 사용하여 컴퓨터/PC/노트북을 종료하려면 “ ” 코드가 있는 기능을
사용해야 합니다 

 

import os
  
shutdown = input("Do you wish to shutdown your computer ? (yes / no): ")
  
if shutdown == 'no':
    exit()
else:
    os.system("shutdown /s /t 1")

 

반응형
반응형

[백준] 1021번 회전하는 큐
    https://www.acmicpc.net/problem/1021

 

1021번: 회전하는 큐

첫째 줄에 큐의 크기 N과 뽑아내려고 하는 수의 개수 M이 주어진다. N은 50보다 작거나 같은 자연수이고, M은 N보다 작거나 같은 자연수이다. 둘째 줄에는 지민이가 뽑아내려고 하는 수의 위치가

www.acmicpc.net


    문제
    지민이는 N개의 원소를 포함하고 있는 양방향 순환 큐를 가지고 있다. 지민이는 이 큐에서 몇 개의 원소를 뽑아내려고 한다.

    지민이는 이 큐에서 다음과 같은 3가지 연산을 수행할 수 있다.
     1.첫 번째 원소를 뽑아낸다. 이 연산을 수행하면, 원래 큐의 원소가 a1, ..., ak이었던 것이 a2, ..., ak와 같이 된다.
     2.왼쪽으로 한 칸 이동시킨다. 이 연산을 수행하면, a1, ..., ak가 a2, ..., ak, a1이 된다.
     3.오른쪽으로 한 칸 이동시킨다. 이 연산을 수행하면, a1, ..., ak가 ak, a1, ..., ak-1이 된다.
    
    큐에 처음에 포함되어 있던 수 N이 주어진다. 그리고 지민이가 뽑아내려고 하는 원소의 위치가 주어진다. (이 위치는 가장 처음 큐에서의 위치이다.) 이때, 그 원소를 주어진 순서대로 뽑아내는데 드는 2번, 3번 연산의 최솟값을 출력하는 프로그램을 작성하시오.

    입력
    첫째 줄에 큐의 크기 N과 뽑아내려고 하는 수의 개수 M이 주어진다. N은 50보다 작거나 같은 자연수이고, M은 N보다 작거나 같은 자연수이다. 둘째 줄에는 지민이가 뽑아내려고 하는 수의 위치가 순서대로 주어진다. 위치는 1보다 크거나 같고, N보다 작거나 같은 자연수이다.
    
    예제 입력 1 
    10 3
    1 2 3
    예제 출력 1 
    0
    예제 입력 2 
    10 3
    2 9 5
    예제 출력 2 
    8

import sys

N, M = map(int, sys.stdin.readline().split())
targets = list(map(int, sys.stdin.readline().split(' ')))
queue = [i for i in range(1, N+1)]

ans = 0
for target in targets:
    plus_index = queue.index(target) # 앞에꺼를 뒤로 넘기는 연산 수
    minus_index = len(queue) - plus_index # 뒤에꺼를 앞으로 넘기는 연산 수
    steps = min(plus_index, minus_index) # 둘 중 최솟값

    # plus는 2번 연산
    # minus는 3번 연산
    if steps == plus_index: sign = 'plus' 
    else: sign = 'minus'

    if sign == 'plus':
        for _ in range(steps):
            temp = queue.pop(0)
            queue.append(temp)
    else:
        for _ in range(steps):
            temp = queue.pop(-1)
            queue.insert(0, temp)
    
    ans += steps
    queue.pop(0)

print(ans)


# 참고  : https://www.acmicpc.net/problem/1021
반응형
반응형

https://codecrazypy.blogspot.com/2023/03/python-mcqs-quiz-1.html

 

Python MCQ's Quiz-1

Here you can find some infomation about exams,educational events and how to prepare for competitive exams likes ssc gd, railway exams,

codecrazypy.blogspot.com

What will be the datatype of the var in the below code snippet?
var = 10
print(type(var))
var = "Hello"
print(type(var))

반응형

+ Recent posts