0Pricing
Mojo Academy · レッスン

初めての.mojoファイル

ファイルを作成してHello, worldを表示します

「初めての.mojoファイル」はCoddyKit上の無料Mojo Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMojo Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Mojo Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

A File to Hold Your Code

Mojo programs live in plain text files. Each one ends with the .mojo extension so the toolchain knows how to compile and run it. 📄

Name It Clearly

Pick a short, lowercase name like hello.mojo. A clear file name makes it obvious what the program does when you come back later.

hello.mojo

The .mojo and .🔥 Twist

Mojo even allows the fire emoji as an extension, so hello.🔥 is valid too. Most people stick with .mojo for everyday work though.

Print Your First Line

The classic first program prints a greeting. In Mojo you use print, just like Python, to send text to the screen.

print("Hello, world!")

Code Goes Inside main

Your runnable code belongs in a function called main. Mojo looks for it as the starting point when the file runs.

def main():
    print("Hello, world!")

Indentation Marks the Block

Like Python, Mojo uses indentation to group code. The print line is indented under main, showing it belongs to that function.

def main():
    print("Hello, world!")

Save the File

Type the code in your editor and save it as hello.mojo. Nothing runs until you save, so this step matters before you try it.

Change the Message

The text inside the quotes is yours to edit. Swap it for a string like your name to make the program feel like your own.

print("Hello, Mojo learner!")

Strings Need Quotes

Any text you print must sit inside quotes. Without them Mojo treats the words as code and reports an error instead of printing.

print("This is text")

One File, One Program

This single .mojo file is a complete program. It has a main function with one job: greeting you. Small, but truly real Mojo.

Ready to Run

With hello.mojo saved, you have everything needed to run it. The next lessons show how to launch it from the command line.

Quick Check

You just created your first source file. What is the standard extension for a Mojo program?

Recap

You made a .mojo file, put a print call inside main, and saved it. That single file is a complete, ready-to-run Mojo program. 🎯

よくある質問

「初めての.mojoファイル」レッスンは無料ですか?

はい。「初めての.mojoファイル」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Mojo Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Mojo Academyコースには全4レッスンが含まれています。

「初めての.mojoファイル」で何を学びますか?

ファイルを作成してHello, worldを表示します ブラウザで直接実行するハンズオンコードでMojo Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Mojo Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのMojo Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「初めての.mojoファイル」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このMojo Academyレッスンでコードを書いて実行できますか?

はい。すべてのMojo Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 初めての.mojoファイル
  2. mainエントリーポイント
  3. mojo runで実行する
  4. Mojo REPLで試す
← Mojo Academyに戻る