Exponentiation Operator in Python Animation in Manim


from manim import *

class CodeFromString(Scene):
    def construct(self):
        self.camera.background_color=BLUE
        code1 = '''a=2
b=5
c=a**b
print(c)
'''
        code2 = '''a=36
b=0.5
c=a**b
print(c)
'''
        code1 = Code(code=code1, tab_width=30,style=Code.styles_list[10],  language="Python", font="Monospace")
        code1.move_to(5.5*LEFT+2.00*UP)
        self.add(code1)
        self.wait(20)
        rt1= MathTex(r"a=2 \hspace{0.55cm} a \Rightarrow  2", font_size=60)
        rt2= MathTex(r"b=5 \hspace{0.55cm} b \Rightarrow  5", font_size=60)
        rt3= MathTex(r"c=a**b \hspace{0.55cm} c \Rightarrow  a^b", font_size=60)
        rt31= MathTex(r"c=2**5 \hspace{0.55cm} c \Rightarrow  2^5", font_size=60)
        rt4= MathTex(r"print(c) \hspace{0.55cm} c \Rightarrow  32", font_size=60)
        rt5= MathTex(r"Output=32", font_size=60)
        rt1.move_to(0.5*LEFT+2.00*UP)
        rt2.move_to(0.5*LEFT+2.00*UP)
        rt3.move_to(0.5 *LEFT+2.00*UP)
        rt31.move_to(0.5 *LEFT+2.00*UP)
        rt4.move_to(0.5*LEFT+2.00*UP)
        rt5.move_to(0.5*LEFT+2.00*UP)
        self.add(rt1)
        self.wait(10)
        self.play(FadeOut(rt1))
        self.add(rt2)
        self.wait(10)
        self.play(FadeOut(rt2))
        self.add(rt3)
        self.wait(10)
        self.play(FadeOut(rt3))
        self.add(rt31)
        self.wait(10)
        self.play(FadeOut(rt31))
        self.add(rt4)
        self.wait(10)
        self.play(FadeOut(rt4))
        self.add(rt5)
        self.wait(10)
        self.play(FadeOut(rt5))
        self.play(FadeOut(code1))
        ####################################################################3
        code2 = Code(code=code2, tab_width=30,style=Code.styles_list[14],  language="Python", font="Monospace")
        code2.move_to(5.5*LEFT+2.00*UP)
        self.add(code2)
        self.play(FadeIn(code2))
        self.wait(20)
        rt1= MathTex(r"a=36 \hspace{0.55cm} a \Rightarrow  36", font_size=60)
        rt2= MathTex(r"b=0.5 \hspace{0.55cm} b \Rightarrow  0.5", font_size=60)
        rt3= MathTex(r"c=a**b \hspace{0.55cm} c \Rightarrow  a^b", font_size=60)
        rt31= MathTex(r"c=36**0.5 \hspace{0.55cm} c \Rightarrow  \sqrt{36}", font_size=60)
        rt4= MathTex(r"print(c) \hspace{0.55cm} c \Rightarrow  6.0", font_size=60)
        rt5= MathTex(r"Output=6.0", font_size=60)
        rt1.move_to(0.5*LEFT+2.00*UP)
        rt2.move_to(0.5*LEFT+2.00*UP)
        rt3.move_to(0.5 *LEFT+2.00*UP)
        rt31.move_to(0.5 *LEFT+2.00*UP)
        rt4.move_to(0.5*LEFT+2.00*UP)
        rt5.move_to(0.5*LEFT+2.00*UP)
        self.add(rt1)
        self.wait(10)
        self.play(FadeOut(rt1))
        self.add(rt2)
        self.wait(10)
        self.play(FadeOut(rt2))
        self.add(rt3)
        self.wait(10)
        self.play(FadeOut(rt3))
        self.add(rt31)
        self.wait(10)
        self.play(FadeOut(rt31))
        self.add(rt4)
        self.wait(10)
        self.play(FadeOut(rt4))
        self.add(rt5)
        self.wait(10)
        self.play(FadeOut(rt5))
        self.play(FadeOut(code2))
        t =Text("Thanks For Watching Video From www.postnetwork.co", gradient=(RED, YELLOW, GREEN), font_size=35)
        self.add(t)
        self.play(Write(t))
        self.wait(8)
        

Leave a Comment

Your email address will not be published. Required fields are marked *

©Postnetwork-All rights reserved.