from tkinter import Tk, Canvas
frame=Tk()
canvas=Canvas(bg='black',height=250,width=300)
coord=(100, 100, 200, 200)
canvas.create_arc(coord,start=0,extent=90,fill='white')
canvas.create_arc(coord,start=90,extent=90,fill='blue')
canvas.create_arc(coord,start=180,extent=90,fill='white')
canvas.create_arc(coord,start=270,extent=90,fill='blue')
canvas.pack()
frame.mainloop()
In the Package Explorer view, select the the current working pydev project i.e. week1lab and click the New > Source Folder... to create a source folder "src", click the New > Pydev Module... in the toolbar. In the Package and Name field, select src and type bmw. Click Finish and Select <empty> from the Template menu.
bmw.py is opened in the editor which contains the default header comments.
Finish the program by copy the code from above. Save and run the module to see your output.
a. x = 3 + 4 - 6 / 2 * 3 b. x = 12 % 5
c. y = 4 d. x = 3
x = y << 2 y = ++x + 4 // x
e. y = 7 f. x = 5
x = 2 * y < y x *= 3**x
Type these statements in python console to check your answers.
from tkinter import Tk, Canvas
frame=Tk()
canvas=Canvas(bg='black',height=250,width=300)
coord=(100, 100, 200, 200)
canvas.create_arc(coord,start=0,extent=90,fill='white')
canvas.pack()
frame.mainloop()
Use print() or echo, id(), and type() functions in python console to check your answers.
Algorithm PRIME. Given a positive integer NUM, this algorithm determine whether or not the numbers is prime. LOOP is an integer loop variable
1. input the number
Read(NUM)
2. determine that the NUM is prime or has divisors other than 1
2.1 determine if number is divisible by 2
If NUM = 2
Then NUM is a prime number
Else If NUM is even
Then NUM is not a prime number and halt
Else 2.11 determine if (NUM divisible by odd integers >= 3 and <= (square root of NUM))
For LOOP := 3 to sqrt(NUM) by 2
Do If (NUM mod LOOP) = 0
Then NUM is not a prime number and halt
3. if we get here, print a message that NUM is a prime number
Write(NUM,"is a prime number");
4. finished
Halt
Write a Python program to determine whether a number is a prime number.
X = (-b + sqrt(b*b- 4*a*c)) / (2*a) ,
and
X = (-b - sqrt(b*b- 4*a*c)) / (2*a)
Thus X can be found if a, b, and c are known. For any set of values for a, b, and c there are two possible answers for X.
Write a Python program to solve the binomial equation. Prompt the user to enter the values a, b, and c. Use only 2 decimal places for all values.
Your output should be formatted as the example below:
When a = 1.00, b = 0.00, and c = -1.00: X = 1.00 or -1.00
Run your program with the following 3 sets of sample data:
1) 1.0 0.0 -1.0
2) 1.0 1.0 -12.0
3) 2.0 3.0 -4.0
4) 0.0 1.0 -1.0
5) 2.0 3.0 4.0