【5秒でわかる】Pythonでランダムな数値を生成する(random.randrange)

Python3

プログラム

import random
hoge = random.randrange(150)
print(hoge)

結果

67

解説

random.randrange(num)
  1. num:数値範囲の最大値

int型の数値を与えると、0から指定した数値までの範囲でランダムな数値を生成します。

結果はint型で返ってきます。

タイトルとURLをコピーしました

Fatal error: Uncaught JSMinException: Unterminated string literal. in /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/cfiltering/lib/library/jsmin-php/jsmin.php:128 Stack trace: #0 /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/cfiltering/lib/library/jsmin-php/jsmin.php(315): JSMin->action(1) #1 /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/cfiltering/lib/library/jsmin-php/jsmin.php(76): JSMin->min() #2 /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/yasakani-cache/yasakani-cache.php(570): JSMin::minify('<script type="a...') #3 /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/yasakani-cache/yasakani-cache.php(925): Yasakani_setting::html_minify('<!doctype html>...', 1, 1, 1) #4 [internal function]: Yasakani_setting::output_cache('<!doctype html>...', 9) #5 /home/miyayamo/miyayamo.com/public_html/wp-includes/functions.php(4339): ob_end_flush() #6 /home/miyayamo/miyayamo.com/public_html/wp-includes/class-wp-hook.php(286): wp_ob_end_flush_all('') #7 /home/miyayamo/miya in /home/miyayamo/miyayamo.com/public_html/wp-content/plugins/cfiltering/lib/library/jsmin-php/jsmin.php on line 128