This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Make a copy of square() and change the name to polygon() | |
Add another parameter named n and modify the body ... | |
so it draws an n-sided regular polygon. | |
Hint: The exterior angles of an n-sided regular polygon are 360/n degrees. | |
import turtle | |
def square(t, length): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Write a function called square() that ... | |
takes a parameter named t, which is a turtle. | |
It should use the turtle to draw a square. | |
import turtle | |
bob = turtle.Turtle() | |
square(bob) | |
turtle.mainloop() """ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace | |
* {b} abc {/b} with: | |
* <b> abc </b> | |
* Use preg_replace() function | |
*/ | |
$str = "{b} abc {/b}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code will throw an Exception Error | |
* Correct the error line | |
*/ | |
class App { | |
public static void main(String[] args) { | |
/** | |
* SOLUTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Import libraries required by the following code | |
*/ | |
/** | |
* SOLUTION | |
*/ | |
import java.util.List; | |
import java.util.ArrayList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Define class constructor and ... | |
* Display the constructor method name | |
*/ | |
$obj = new A(); | |
class A | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Write constructor and method for Output class. | |
* The output() prints the <name> instance variable | |
*/ | |
class App { | |
public static void main(String[] args) { | |
Output o = new Output("John"); | |
o.output(); // John | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Define Dog class which | |
* Dog class must implement the correct class | |
*/ | |
class App { | |
public static void main(String[] args) { | |
Dog d = new Dog(); | |
d.bark(); // The dog is barking | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Define abstact class Animal | |
* Class Animal contains two methods, eat() and showName() | |
* One of the method is abstract | |
*/ | |
class App { | |
public static void main(String[] args) { | |
Dog d = new Dog(); | |
d.setName("MyDog"); | |
System.out.println(d.name); // MyDog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Define MyMath.floor() method using java.lang.math method | |
class App { | |
public static void main(String[] args) { | |
double n = MyMath.floor(12.3); | |
System.out.print(n); // 12.0 | |
} | |
} | |
*/ |