TRENDING NEWS

POPULAR NEWS

How Do I Make This Code Repeat To Make 2 Triangles Instead Of Just One

How do I repeat questions in Python?

You want the "while" condition to repeat the input, not the "print grade". Try something like this:

grade=input("enter a grade:")
while grade<1 and grade>100:
... print "Grade must be from 1 to 100. Try again."
... grade = input("enter a grade:")
print grade

The ... dots are just for indentation. The idea is that the indented suite only if, and repeatedly while, the grade value entered is outside the legal range. You can hack up a loop so that you only need one statement that calls the input() function, but the logic isn't as clear as this, and you'll often find that you want a different prompt on later attempts anyway.

Math, How many triangles can be formed?

ok i dont know what the person before me did but im in math B so i know how to do these problems.
First draw a traingle and label the points a, b, c. fill in angle B and the sides which are opposite the angles.
Next you are going to plug everything into the formula
SinA = SinB
----------------------
A B
so we end up with
sinA = sin108
--------------------
17 28
cross multiply by pluging it into ur graphing calculator and we get
16.16796078= 28sinA
----------------------------------
sin28 sin28
A = 34.43
A = 34

Now we know that all triangles measure 180 and we have 2 angles so 108 + 34 =142, 180-142 =38 so we can make one triangle.

In order to get the next angle measurment i use the chart . imm trying my best to draw it

S l A
----------
T l C

u can remember this with the acronym all students take calc. and the a means all numbers are positive the s means sin is positive, the t means tan is positive and the c means cos is positive. so we have our angle measurment of sin34 which fits in quad A because it is positive acute angles only. Then we can also use it in the S quadrant and the formula for the S quadrant is 180-x so we plug in 180-34 and we end up with 146 and that doesnt fit inot our triangle.

Sorry its so long haha and this is only the first one. u can use the formula to get the second. and also when i did SinA = Sin B and the a and b are under each thing not together

Degenerate can mean different things in different circumstances, but I'll assume you mean triangles with an angle of [math]180[/math]. In such triangles, the sum of the lengths of two sides is equal to the length of the third side.I'll further assume that you are doing this on a computer, since .5 seconds is awfully short for a person.Let [math]n[/math] be the number of lengths you have.The totally naive approach: For each set of three lengths, check if two sum to the third.This runs in [math]O({{n}\choose{3}})[/math] time, aka [math]O(n^3)[/math]Slightly less naive: make a new list of all sums of pairs and count the intersections with the original list.still [math]O(n^3)[/math]Getting somewhere: sort the list of lengths. Then generate a new list of sums of pairs that is also sorted. Finally, find the intersection by binary searching for each of the elements of the first list in the second.Properly done, this is [math]O(n^2)[/math] because making the second list is the bottleneck.Making the second list already sorted is a little tricky. See 4b for a hint on how to do it. In practice though, just generating it normally and using the right sorting algorithm will be almost as fast.Tuning it for practical application:Sort the list: [math]O(n\log(n))[/math]Generate the second list dynamically while checking for intersections with the first. This is still [math]O(n^2)[/math], but you don't need to store the whole thing in memory and the search part becomes much faster. Instead of binary search for each element, you use a method similar to that of combining two sorted arrays reading through each only once.EDIT: we are no longer allowed to use loops.So here is a naive Python implementation.import itertools
pairs=itertools.product(lengths, lengths)
pairsums=list(map(lambda x: sum(x),pairs))
count=sum(list(map(lambda x: x in lengths, pairsums)))/2
We divide by two because we actually counted each triangle twice: as (a,b,c) and as (b,a,c).The performance of this can certainly be improved, but it's actually not all that slow unless your list is huge.

try (code appears good to me)Creating a web page with a single background image not a tiled background. Perfect Full Page Background Image | CSS-Tricks Edit: code is straight forward . just copy paste on top of the existing code for the page you see in editor . either use WYSIWYG(visual tool) which might have this feature (single image with no repeat)or use this code . me and you know that you are a 10th standard guy. but browser does not understand . it plays by the rules it knows.

How do I use this code to make a background image instead of a background color?

The part "

" set the background black. Change black to color you want to use. Example:

"


There's two center tags which is a no-no. Your link to image didn't come out so this is just a guess:





The "
"s are line breaks used for separation of items. Causes a break to a new line for content following it. Some may be removed, but I wouldn't even try to tell you with so little to work from. Of course, your "br />" tags didn't show up and those are done the wrong way anyway.

Font tags have been out of use for ages.

Your table is the one that has the background image in it. If it worked as you said, don't move that code to the div container.

Ron

How can I repeat a block of Javascript/jQuery code?

I just started teaching myself a bit of Javascript with the jquery library and ive ran into an issue that I cant seem to hash out.

I have this block of function that is supposed to work like a slide show - however - it is not timed but based on the click of an arrow. My problem is, I have no idea how to get the code to repeat once it ends. Instead, the code seems to back up a step and then do the last function again. Mind you, im an amateur and trying to figure it out by error so if my code is completely horrible or bad form, please understand.

The code I have is:

$(document).ready(function(){
$(".right").click(function(){
$(".home").hide();
$(".home2").fadeIn(750);

$(document).ready(function(){
$(".right").click(function(){
$(".home2").hide();
$(".home3").fadeIn(750);

$(document).ready(function(){
$(".right").click(function(){
$(".home3").hide();
$(".home").fadeIn(750);

});
});

});
});

});
});

after the last $(".home").fadeIn(750); occurs i want the block to return to top of the block to be ready to be executed from another click of the arrow. Thanks for any and all help.

First you must know the formula that if one of the vertices of a triangle is origin and the other two vertices are (X1,y1),(x2,y2) then orthocentre of the triangle is equal to (k(y2-y1),k(x1-x2) where k=x1.x2+ y1.y2 / x1.y2-x2.y1now lets check this with example .Q.find the orthocentre of triangle with vertices(2,5),(4,7),(-1,3).sol->here we dont have an origin point so by simple operation we will get that point i.e lets make (2,5) as origin then(2,5)-(2,5)=(0,0) (4,7)-(2,5)=(2,2)=(x1,y1) (-1,3)-(2,5)= (-3,-2)=(x2,y2)now we got three new points (0,0),(2,2)and (-3,-2)according to the formula k=2.-3+2.-2/2.-2-(-3).2so k= -6–4/-4+6= -10/2=1=-5so the orthocentre is (5.(-2–2),5.(2-(-3))=(5.(-4),5.5)=(-20,25) now add (2,5) to point because at the starting of the point so orthocentre is (-18,30)

How do I get one solid background image (instead of lots of the same picture using CSS)? Thanks.?

First, the image will NOT take up the whole screen unless it is sized for your screen. For a web page, it is NOT your screen size/res that you worry about. It is the expected viewer's browser window size. For example, I have a 22-inch monitor at hight res, but I keep by browser window sized to 1024x768. I can quickly resize to 800x600 or any other size I need to check a web page.

A background image can not be resized except using some CSS trickery. CSS 3.0, once supported fully, will allow this. For now, you have to size the image within a graphics editor or use any one of the many free online image resizer. Enlarging an image is ok provided you have a good quality, hi-res image to start with or the image was made as a vectored graphic.

For CSS background image, you need to set at least a width for the body tag. You will need a width and height set for a div container.

CSS Example:

body {
width: XXXpx;
margin: 0 auto;
background: #fff url(path to image) no-repeat center scroll;
}

Change "#fff" (white) to background color wanted while image loads on slower computers. Change "scroll" to "fixed" if you want page contents to scroll over background image.

Ron

TRENDING NEWS