Inverted Solid Right Triangle
Given an integer number
The first line of input is an integer
In the given example the solid right angled triangle of side
4. Therefore, the output should be
* * * *
* * *
* *
*
Hollow Right Triangle
Given an integer number
The first line of input is an integer
In the given example the hollow right angled triangle of side
4. Therefore, the output should be
* * * *
* *
* *
*Example 4: Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.
Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.
Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. Try to be creative with your examples to demonstrate that you invented them yourself.
Example 1: Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.
Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which.
Example 3: Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.
You are part of the Web development Team, currently designing a Web site for A company called Nkwali Yenkosi that designs and sells leather clothing and accessories. The Web site is made up of 5 Web pages (Home, About the leather, DIY Methods, Brick & Mortar and Shop Now). You are responsible for creating the Shop Now Web page and 2 Web pages connecting to it.
You must follow the following instructions to complete the Shop Now Web page, use the Assets folder provided for resources such as images required and font family to be used.
Compile Time Polymorphism IV
Develop a program to overload binary operators.
The class Complex has the following public attributes
Data typeVariable nameintrealintimaginary
Include default constructor to initialize real and imaginary values to 0
Include the following functions in the Complex class and overload the binary operators
Member functionFunction descriptionvoid getvalue()This function is used to read .
void display()This function will display the result value
Sample Input and Output :
[All texts in bold represents input and rest represents output statements]
Enter the value of Complex Numbers a,b :4 5
Enter the value of Complex Numbers a,b :7 8
Input Values :
Output Complex number : 4+5i
Output Complex number : 7+8i
Result :
Output Complex number : 11+13i
Output Complex number : -3-3i
Create a program that reads the users name and year of birth from input(keyboard), then print out their name and age in decades(find out the meaning). Sample run 1: Sample run 2: Enter your name: Hausiku Enter your name: Johanna Enter your year of birth:1999 Enter your year of birth:2005 Output: Hello Hausiku, you have lived for 2 Output: Hello Johanna, you have lived for 1 decade(s) decade(s)
Create a program that when run with two numbers as CMD arguments, it prints out the difference and product separated by space[Hint: CMD arguments need to be converted to integers]: Sample run 1: Sample run 2: java lab02_task02 12 3 java lab02_task02 2 5 Output: 9 36 Output: -3 1
Write a program that simulates the movement of an elevator. Create class called button that abstracts a push button located in the elevator. Use an numerated type to represent its state either pressed or not pressed. Write functions to change the state,to retrieve the state. If button is pressed that is already in the pressed state, then display error message. Write a class called elevator that contains the data members: An array of button objects, An integer representing which floor the elevator is currently on, A constant integer representing the top floor for the elevator. Its value comes from the one formal argument in the elevator constructor function. Assume that the button floor is always number 1.Write a member function for the elevator class that allows the user to press any number of valid buttons. Assume that button number means that it is time to close the elevator doors. When this happens, the elevator must move to a floor that has a corresponding button pressed.