PHYS 104 Quiz Solutions

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/15

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards
for stuff in range(5):
	print(stuff)	

0
1
2
3
4

2
New cards
for i in range(5):
	if (i==1) or (i==3):
	     print("hello")

hello
hello

3
New cards
myfamily=["Paul", "Chris", "Mary Ann", "Alan", "Stu", "Rose", "Xyla", "Kate", "Peter", "Addy", "Jamey"]
for person in myfamily:
	print(person)

Paul
Chris
Mary Ann
Alan
Stu
Rose
Xyla
Kate
Peter
Addy
Jamey

4
New cards
myfamily=["Paul", "Chris", "Mary Ann", "Alan", "Stu", "Rose", "Xyla", "Kate", "Peter", "Addy", "Jamey"]
i=0
for person in myfamily:
	if (i==1) or (i==3):
	      print(person) 
	i=i+1

Chris
Alan

5
New cards

How would I do the same thing as in Problem 4, but using the construction “for i” followed by some other commands? Write out the full code (we’ll be generous with punctuation).

i=0
for i in range (len(myfamily)):
	if (i==1) or (i==3):
	  print(myfamily[i])
	i+=1

6
New cards

Explain how you would do the same thing as in Problem 3, but using the construction “while” followed by some other commands? Write out the full code (we’ll be generous with punctuation).

i=0
while i<(len(myfamily)):
	print(myfamily[i])
	i+=1

7
New cards
def f(x):
	return(x*x)

a=2
b=f(a)
print("I called the function on the number %f, and it returned %f" %(a,b))

I called the function on the number 2.000000 and it returned 4.000000

8
New cards
def add10(x):
	x+=10
	return(x)

for s in range(5):
	print(add10(s))

10
11
12
13
14

9
New cards
students=["Sigourney", "Meredith", "Chung-pei", "Geraldo", "Tuck"]
j=472
for student in students:
	j+=1
	print("%d %s" %(j, student))

473 Sigourney
474 Meredith
475 Chung-pei
476 Geraldo
477 Tuck

10
New cards
def add10(x)
	return(x+10)

y=14
samantha=42
print(add10(y))
print(add10(100))
print(add10(samantha))

24
110
52

11
New cards

Describe what right ascension is.

Right ascension is one of the two coordinates we use to describe the position of stars and galaxies. It's analagous to longitude around the earth. It's measured in hours (24 hours in a circle) or degrees (360 degrees in a circle.)

12
New cards

Describe what declination is.

Declination is one of the two coordinates we use to describe the position of stars and galaxies. It's analagous to latitude around the earth. It's measured in degrees with 0 being on the celestial equator, +90 degrees at the North Celestial Pole, and -90 at the South Celestial Pole.

13
New cards

Describe what redshift is.

Redshift is a phenomenon where electromagnetic radiation (like light) from an object undergoes an increase in wavelength, shifting to the red end of the electromagnetic spectrum. This can be caused by the object moving away from the observer (Doppler effect) or by the expansion of space itself (cosmological redshift).

14
New cards

Describe what magnitude is.

In astronomy, magnitude is a logarithmic measure of the brightness of a celestial object, as seen by an observer. It can refer to apparent magnitude (how bright an object appears from Earth) or absolute magnitude (how bright an object would appear if it were observed from a standard distance of 10 parsecs).

15
New cards

Why would restricting redshift to a number between .3 and .4 (for example) give you a “slice” of the universe?

Redshift is proportional to distance. So if you restrict redshift to between .3 and .4, you're saying you only want to see galaxies that are a certain distance away from us. The notion of a "slice" is a little weird when you consider the whole universe, because then you'd get a sphere of galaxies that were that distance away. But if you consider that you're looking in one particular direction in the sky, all the galaxies in that direction will sort of look like a slice, or a slab.

16
New cards
import pandas as pd
fruits=pd.read_csv('fruits.csv')

print(fruits.fruit)
print(fruits.shape[0])

0	apple
1	orange
2	banana
3	blueberry
Name: fruit, dtype: object
4

Explore top flashcards