PYTHON
Fractal Drawing
We will draw a recursively defined picture in this program.
Create a function def fractal(length, spaces). This function will print out a certain number of stars * and spaces.
Once your function works, prompt the user for an integer x and execute fractal(x,0). You will not receive credit if your function is not recursive.
If the input is not an integer > 0, ask again. Your program should exit after successfully drawing a Fractal.
You may create any additional functions you want to complete this assignment. Only the fractal function must be recursive.
Example 1
Fractal Generator Enter an integer > 0: Cats Enter an integer > 0: 3 * *** *
Example 2
Fractal Generator Enter an integer > 0: 8 * ** * **** * ** * ******** * ** * **** * ** *
code:
def fractal(length, spaces):
if length == 1:
print(spaces * " ", '*')
else:
fractal(int(length / 2), spaces) #Recursive call
print(spaces * " ", length * "*")
fractal(int(length / 2),spaces + int (length / 2)) #Recursive call
def getinput():
x = input("Enter an integer > 0 :")
if x.isdigit() :
return int(x)
if _name_ == "_main_":
x = getinput() #Function to get input
fractal(x, 0)
else:
return getinput()
PYTHON Fractal Drawing We will draw a recursively defined picture in this program. Create a function...
Create a FRACTAL Javafx program ; it should draw some kind of fractal image ( a pattern that repeats). .... you can start with code similar to this (but I DO NOT want you just doing this simple one.. do a more complex image) //call the following method from your start() method after you create an empty pane (start with your drawHouse code that you did last week): Pane pane = new Pane(); //create an empty pane drawCircle(pane, 50,50, 20); //draw...
/*
* File: HFractal.cpp
* ------------------
* This program draws an H-fractal on the graphics window.int main()
{
*/
#include "gwindow.h"
/* Function prototypes */
void drawHFractal(GWindow & gw, double x, double y, double
size, int order);
/* Main program */
int main() {
GWindow gw;
double xc = gw.getWidth() / 2;
double yc = gw.getHeight() / 2;
drawHFractal(gw, xc, yc, 100, 3);
return 0;
}
/*
* Function: drawHFractal
* Usage: drawHFractal(gw, x, y, size, order);
* -------------------------------------------
*...
Write the Code in C program. Create a random password generator that contains a user-specified number of characters. Your program should prompt the user for the desired length of the password. Length of password: To create your password, use the random number generator in the stdlib.h C library. To generate random numbers, you will need the srand() and rand() functions. srand(seed) is used to "seed" the random number generator with the given integer, seed. Prompt the user for the seed...
this can be done in one class or two separate classes,in java
thanks!
You will implement and test several short recursive methods below. With the proper use of recursion, none of these methods should require more than a dozen lines of code. Test all these in the same class. Keep adding methods and testing until all are working 5. A Fractal Pattern Examine this pattern of stars and blanks, and write a recursive method that can generate patterns such as...
Python. This program is not finished. It lost a if condition. How to finish this program? Thank you. def area(length,width): return length*width def main(): print("this program calculates the results of formulas") print("For the area pf a rectangle ,type Area \n followed by the length and width of the rectangle") print("For example-area 4 6") userInput=input(">>>") createlist=userInput.split(" ") print("creatlist[0]="+creatlist[0]) print("createlist[1]="+createlist[1]) print("createlist[2]="+createlist[2])
For Python debugExercise12.py is a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. By debugging these programs, you can gain expertise in program logic in general and the Python programming language in particular. def main(): # Local variable number = 0 # Get number as input from the user. number = int(input('How many numbers to display? ')) # Display the numbers. print_num(number) # The print_num function is a a recursive function #...
C++
3. Write a program that recursively calculates n factorial (n!) a) Main should handle all input and output b) Create a function that accepts a number n and returns n factorial c) Demonstrate the function with sample input from console. n! n * n-1 * n-2 * n-3, for all n > 0 For example, 3!-3 21-6 using a recursive process to do so. Example output (input in bold italics) Enter a number: 5 5120
In python using a def main() function, Write a function that will print a hello message, then ask a user to enter a number of inches (should be an integer), and then convert the value from inches to feet. This program should not accept a negative number of inches as an input. The result should be rounded to 2 decimal places(using the round function) and printed out on the screen in a format similar to the example run. Use a...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....