Hanwool Codes RSS Tag Admin Write Guestbook
전체 글 (45)
2023-01-18 06:13:37

Input and Output | HackerRank

 

Input and Output | HackerRank

Learn to take in the input and print the output. Take three number as input and print their sum as output.

www.hackerrank.com

 

Goal

 

Read 3 numbers from stdin and print their sum to stdout

 

 

Solution

 

This challenge is to practice reading input from stdin(standard input stream) and printing out to stdout(standard output stream).

 

// Input and Output

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int a, b,c ;
    int result = 0;
    cin >> a >> b >> c;
    result = a + b + c;
    cout << result << endl;
    return 0;
}

 

 

 

2023-01-18 06:06:40

Say "Hello, World!" With C++ | HackerRank

 

Say "Hello, World!" With C++ | HackerRank

Practice printing to stdout.

www.hackerrank.com

 

Goal

 

Solution

 

This is simple challenge to print "Hello, World!" to stdout. We can use easily an object of class iostream. "std::cout."

 

// Say "Hello, World!" With C++

#include <iostream>
#include <cstdio>
using namespace std;

int main() {

    cout << "Hello, World!" << endl;
    return 0;
}

 

2023-01-10 07:40:22

Today, I will show how to convert m4a file into mp3 file in python.

My test environment is OS : Windows 10 and Python version : 3.7.6

 

Convert m4a file into mp3 file in Python

 

Firstly, you need to install python library "pydub" 

 

GitHub - jiaaro/pydub: Manipulate audio with a simple and easy high level interface

Manipulate audio with a simple and easy high level interface - GitHub - jiaaro/pydub: Manipulate audio with a simple and easy high level interface

github.com

 

But to use pydub library, you need to install ffmpeg or libav.

 

FFmpeg

Converting video and audio has never been so easy. $ ffmpeg -i input.mp4 output.avi     News July 22nd, 2022, FFmpeg 5.1 "Riemann" FFmpeg 5.1 "Riemann", a new major release, is now available! Some of the highlights: add ipfs/ipns protocol support dialogu

www.ffmpeg.org

 

GitHub - libav/libav: Libav github mirror, clone of git://git.libav.org/libav

Libav github mirror, clone of git://git.libav.org/libav - GitHub - libav/libav: Libav github mirror, clone of git://git.libav.org/libav

github.com

 

You can install ffmpeg-downloader package with below command.

pip install ffmpeg-downloader
ffdl install --add-path

The --add-path option adds the installed FFmpeg folder to the user's system path. In Windows, you need to add your PATH to use ffmpeg library. After add PATH, please reopen python interpretor or other script editor to run ffmpeg properly.

 

If you have other OS, you can check ffmpeg homepage or pydub github page. They explain details how to install ffmpeg in your OS.

 

I provide you sample m4a file to test your script. You can see more free m4a files here.

sample3.m4a
1.66MB

 

 

The sample source code is below.

from pydub import AudioSegment

song = AudioSegment.from_file("sample3.m4a")
song.export("sample3.mp3", format="mp3")

 

If you look at pydub github page, you can convert m4a file into any audio format file.

 

 

 

If you have any question, please write a comment!

'software Engineering > python' 카테고리의 다른 글

How to convert HEIC file into PNG in Python  (0) 2023.01.09


Hanwool Codes. Designed by 코딩재개발.