■21/2/10 7:30PM
Python
def oex(): #globalつけるかつけないかでローカル変数かを決める global vibe rotion = 'g' vibe = 'Pink'
rotion = 'a'vibe = 'Gray'print(vibe)oex()print(vibe)print(rotion)#defは先んじて宣言が必要
###################################
x = 'Aho'def sexWax(a = x): print(a)
sexWax()sexWax('Baka')#関数の初期値は先んじて宣言が必要
###################################
import random
class Unco: init_size = 1 init_color = '茶' def __init__(self, size = init_size, color = init_color): self.size = size self.color = color def wayBy(self): return ['Ketsu','Shiri','Oido'] def getUnco(self, how): how = how[random.randrange(0, 3, 1)] return 'Size' + str(self.size) + 'で色が' + str(self.color) + 'の奴を手法は' + how #クラスの中はselfを付ける
kuso = Unco()how = kuso.wayBy()if len(how) < 1: how = 'Anal'way = kuso.getUnco(how)print(way)
###################################
import random
class Ctl: def __init__(self): self.flag_ok = 1 def run(self): for num in range(random.randrange(0, 3, 1)): print(num) if num == 1: self.flag_ok = 0 print('マッチしました') break
exe = Ctl()exe.run()
while True: if exe.flag_ok == 1: exe.run() else: print('終了します') break
@/// BANGBOO BLOG ///