Is there any way I could tidy this code and make it look better and more appealing?  import csv math_class = input ("Which math class would you like to see the results of?") while math_class not in ['1','2','3']:     math_class = input ("Which math class would you like to see the results of?") sort = input ("How would you like to sort the results alphabetical, highest or average:\n") while sort not in ["alphabetical","highest","average"]:     sort = input ("How would you like to sort the results") class_file_names = ['Class 1.csv', 'Class 2.csv', 'Class 3.csv'] scan = open(class_file_names[int(math_class)-1], 'r+') rows = csv.reader(scan) data = [] next(scan)  for row in rows:     data.append(row) scan.close()  if(sort == "alphabetical"):     word = "- Highest Score on test:"     sorted_= sorted(data, key=lambda name: name [0])     field = 5  if(sort == "average"):     word = "- Average Score"     sorted_ = sorted(data, key=lambda average: average[4], reverse=True)     field = 4  if(sort == "highest"):     word = "- Highest Score on test:"     sorted_ = sorted(data, key=lambda total: total[5], reverse=True)     field = 5  for row in sorted_:     print(str(row[0]), word, str(row[field])) input ("Sort Complete, press any key to close the program.")   If there is no way I could clean up the code, then that's fine as it does what I want it to (it's just that I thought the code could look more appealing than it already is).
This code is part of a larger code that generates an Arithmetic Quiz, although the code I have show below just saves the score that the user got on the test and their name. When saving the code it checks if the user has taken the quiz before. If the user has taken the quiz before it saves it as 'Older Score' or 'Oldest Score', however if the user has not taken the quiz before it generates a new row for them. Additionally it works out the average score and highest score for all users it has the data for. For my task I'm supposed to make the code as short as possible.  name = ""+first_name+" "+last_name rows_data = [] class_file_names = ['Class 1.csv', 'Class 2.csv', 'Class 3.csv'] scan = open(class_file_names[int(math_class)-1], 'r+') rows = csv.reader(scan) for row in rows:     rows_data.append(row) scan.close() class_file_names=['Class 1.csv', 'Class 2.csv', 'Class 3.csv'] csvfile=open(class_file_names[int(math_class)-1], 'w', newline="") fieldnames = ['Student Name', 'Oldest Score', 'Older Score', 'Latest Score', 'Average', 'Highest'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() nameFound=False for x in rows_data[1:]:     if x[0] == name:         x[3]=x[2]         x[2]=x[1]         x[1]=str(score)         x[4]=(int(x[1])+int(x[2])+int(x[3]))/3         x[5]=max(x[1],x[2],x[3])         nameFound=True     writer.writerow({'Student Name': x[0], 'Oldest Score': x[3], 'Older Score': x[2], 'Latest Score': x[1], 'Average': x[4], 'Highest' : x[5]})  if nameFound==False:     writer.writerow({'Student Name': name, 'Latest Score': score, 'Older Score': '0', 'Oldest Score': '0', 'Average': score, 'Highest': score}) csvfile.close() input("Test complete! Press anything to close.")
Possible point location algorithm I need to calculate possible point location based on its speed and some other factors. For example, there is a man in the middle of the forest and I need to calculate his possible location at some time periods. There are few facts about his movement:   His speed differs at certain periods of time - it can be raining, or it can be super hot - speed lowers / increases; Some objects in space - swamps, rocks - can lower his speed as well; At some time periods the man does not move at all.   So, here is the question - is there any algorithm that can calculate possible location of the man based on following parameters? The output should be a polygon for every given time_period.  {   time_periods: [{     from: 2012-12-12T20:00:00,     to: 2012-12-12T22:00:00,     speed: 5   }, {}],   objects: [{     geodata: POLYGON(...),     speed_modifier: 0.5   }, {}] }   Generated polygons will be visualized on the map afterwards. Solving linear congruences by hand: modular fractions and inverses When I am faced with a simple linear congruence such as  $$9x \equiv 7 \pmod{13}$$ and I am working without any calculating aid handy, I tend to do something like the following:  "Notice" that adding $13$ on the right and subtracting $13x$ on the left gives: $$-4x \equiv 20 \pmod{13}$$  so that $$x \equiv -5 \equiv 8 \pmod{13}.$$  Clearly this process works and is easy to justify (apart from not having an algorithm for "noticing"), but my question is this: I have a vague recollection of reading somewhere this sort of process was the preferred method of C. F. Gauss, but I cannot find any evidence for this now, so does anyone know anything about this, or could provide a reference? (Or have I just imagined it all?)  I would also be interested to hear if anyone else does anything similar. What is the weight equation through general relativity? The gravitational force on your body, called your weight, pushes you down onto the floor. $$W=mg$$ So, what is the weight equation through general relativity? Syntax of bash alias definition I'm using Cygwin, and have installed all the developer packages as well as most if not all of the other packages. When I provide an alias for gcc, I get the error  -bash: alias: gcc: not found   What could I be doing wrong?  I am typing the following command into the terminal:  alias gcc "gcc -ansi -Wall -g -O0 -Wwrite-strings -Wshadow -pedantic-errors -fstack-protector-all"   FYI, this alias works on other systems. Request of a domain with no virtualhost in apache ends to default virtualhost If I ask Apache for domain.com that has no Virtual Host setup in Apache configuration, Apache will show the default Virtual Host. How can I prevent this from happening or simply drop the connection? Is there always an equilibrium point in space for gravity? Creating geodatabase feature class using geodatabase table schema with ArcPy? Is there a way in ArcPy to create an empty polygon geodatabase feature class that will acquire the schema of a geodatabase table?  I know that it's possible in ArcCatalog (New -> Feature Class and then import all the fields from a table) but I wonder if it can be written in a Python script.  The CreateFeatureclass_management tool allows only Feature Layers as schema templates. How about a "Irritable" badge for someone who downvotes often? EDIT : How about a forced comment   dialog...which forces the user's to   comment when they downvote otherwise   they can't....right now it just shows   a popup to suggest posting a   comment...maybe this is little too   strict...but i just find it annoying   when ppl downvote and leave no   comments....   How about having a badge "Irritable" for a user who downvotes over 20 times in a month and then have maybe further "Furious" for over 50 downvotes in a month....just a fun suggestion...since i see people downvote like crazy at times...there should also be a way to downvote a comment i think in addition... The set of all finite subsets of the natural numbers is countable 32-bit vs. 64-bit systems Sometimes you see a video of a fan or a propeller spinning very fast, and the apparent rotation is distorted. The fan can appear to be moving in the opposite direction of rotation, or even stationary. This optical illusion is known as the wagon-wheel effect. If I understand correctly, this occurs because the camera framerate is slower than the frequency at which the fan makes one rev, so stroboscopic effects should be expected.   Does the wagon-wheel effect occur only in videos, or can we observe it just with the eye? New Beamer Version: Transparent Title Page Boxes Consider the following file:  \documentclass{beamer}  \setbeamercolor{title}{bg=red} \setbeamercolor{author}{bg=yellow} \setbeamercolor{date}{bg=} \setbeamercolor{institute}{fg=red,bg=green}  \title{TitelTitelTitel} \author{meiermueller} \institute{Institute} \date{lalala}  \begin{document}  \usebackgroundtemplate{\color{blue}\rule{20cm}{15cm}}    \begin{frame}    \titlepage  \end{frame} \end{document}   On one of my computers (using MiKTeX 2.9 and beamer 2015/01/05 3.36), the result is the following:    Note how, in particular, the date box has a transparent background  On my other computer, I installed a new MiKTeX version (2.9.6800), including beamer 2018/09/02 v3.52, and get this:    Here, the date field has a white background, and I cannot seem to get it to be transparent.   Apparently, the difference has some relation to the beamer version, or maybe some other change in the new MiKTeX version.  But what ist the reason, and how do I get transparent backgrounds? transforming ordinary generating function into exponential generating function Show a connected metric space (X,d) is $\epsilon$-chainable for $\epsilon &gt;0$       $\epsilon$-chainable Definition      (X,d) is $\epsilon$-chainable if given any two points $a,b \in X$, $\exists$ a finite set $\{ x_0,x_1,...,x_n\}$ of points in X with $x_0 = a$, $x_n=b$ and $d(x_{n-1},x_n)&lt;\epsilon$, $\forall$ n      Clopen Definition      A set is clopen $iff$ its boundary is empty      Connected Metric Definition      Let $(X,d)$ be a metric space. It is connected $iff$ it has no proper subsets which are clopen      The following are equivalent:         $X$ is connected   The only subsets of $X$ that are clopen are $\emptyset$ and $X$   $\nexists$ non-empty, disjoint, open sets $A$ and $B$ such that $X=A\bigcup B$   $\nexists$ non-empty, disjoint, closed sets $A$ and $B$ such that $X=A\bigcup B$         Theorem      Let $(X,d)$ be a metric space, and let $S$ be any subset of $X$. Then $S$ is closed $iff$ $S^c$ is open.     So how would someone show this exactly?  Let the set $A$ be the set of all elements in $(X,d)$ that can be reached from $a\in X$ in a finite number of steps with length less than $\epsilon$.  Does this mean that there should be no isolated points? (an isolated point would be at distance infinity from any other point, or distance zero from itself, since $\epsilon &gt;0$ we don't want this?)  Knowing that $X$ is connected $\implies$the only subsets of X that are clopen are $\emptyset$ and $X$  Also, by construction of A;   A is the set of all $\epsilon$-chains between any element and $a$  And, so $A^c = \emptyset$ if $A$ was $\epsilon$-chainable (because A has to have a path from all elements to a, for this to be true, the complement wouldn't have anything in it)  Leaving only $A$ as the remaining clopen set  Does this make any sense? Or should an alternative be used, and how to formalize it.  Thanks. Strictly increasing sequence $\{ a_k \}$ of positive integers such that $\sum 1/{a_k}$ is finite For closed subsets $A,B \subseteq X$ with $X = A \cup B$ show that $f \colon X \to Y$ is continuous iff $f|_A$ and $f|_B$ are continuous. I was just trying to solve an exercise in Munkres' Analysis on Manifolds to get better at continuous functions and topology in $\mathbb{R}^{n}$, and I got stuck. Here it is:      Let $X = A \cup B$, $A$ and $B$ are subspaces of $X$. Let $f:X \rightarrow Y.$ Suppose that the restricted functions $f_{|A}:A \rightarrow Y$ and $f_{|B}:B \rightarrow Y$ are continuous. Show that if both $A$ and $B$ are closed in $X$, then $f$ is continuous.    Our definition of continuity is:  $f$ is continuous at $x \in X$ if for each open set $V$ of $Y$ containing $f(x)$, there is an open set $U$ of $X$ containing $x$ such that $f(U) \subset V$. $f$ is continuous if it is continuous at each point of its domain.  What I've tried so far:  Suppose $A$ and $B$ are closed in $X$. Suppose $A \cap B = \emptyset$. Then $X -A$ is open in $X$. But $X - A = B$ which is closed in $X$, which is a contradiction. Hence, $A \cap B \ne  \emptyset$. I'm not sure if this will be useful in the problem or not. If $x \in X$, then it's either in $A$ or in $B$. Suppose without loss of generality that it's in $A$. Then for all open sets $V$ of $Y$ s.t. $f(x) \in V$, $\exists$ an open set $U_{1}$ of $A$ s.t. $U_{1} \subset A, a \in U_{1}$ and $f(U_{1}) \subset V$. This is almost what we want, except that we want to find an open set $U$ of $X$ s.t. $U \subset A, a \in U$ and $f(U) \subset V$. This is because $U_{1}$ being open in $A$ does not necessarily mean that it's open in $X$ because $A$ is closed in $X$. (i know how to expand this argument out if needed) My idea now is to try to find a subset $U$ of $U_{1}$ such that $U$ is open in $X$. We have two cases:  (1) $U_{1}$ does not intersect the boundary of $A$. (2) $U_{1}$ intersects the boundary of $A$. Now I'm not sure what to do. I'm wondering if it would help to investigate the relationship between Bd(A) and Bd(B).. In any case (no pun intended), any help/advice would be greatly appreciated. :)  Sincerely,  Vien biblatex custom reference I've been searching for a way to create "Custom References" with biblatex, but haven't found a solution to my problem. Among "normal sources" like Journal Articles, I need other references where I can put a custom sentence in it. Like "[3] This was performed by someone else".  Is there an option to do that?   \documentclass{scrreprt} \usepackage[refsection=chapter,style=chem-angew]{biblatex} \usepackage[english]{babel} \usepackage[T1]{fontenc} \usepackage[ansinew]{inputenc} \begin{filecontents}{biblio.bib}  @article{entry1,      author = "George D. Greenwade",     title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",     year = "1993",     journal = "TUGBoat",     volume = "14",     number = "3",     pages = "342--351",            url=" www.ctan.org" }  \end{filecontents}  \addbibresource{biblio.bib}  \begin{document} \chapter{Test Chapter One} \cite{entry1} So far so good, now I need another reference that says 'This was performed by someone else'. \printbibliography[heading=subbibliography]  \end{document} What kind of node is this?    Image from this What is a NullPointerException, and how do I fix it? What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? What's the best way to build a string of delimited items in Java?