<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>C0ns0l3art&#039;s Bl0g</title>
	<atom:link href="http://consoleart.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://consoleart.wordpress.com</link>
	<description>I am starting with the man in the mirror</description>
	<lastBuildDate>Thu, 19 May 2011 08:46:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='consoleart.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/36531eb3f440708d955f5f5aee1a4b1e?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>C0ns0l3art&#039;s Bl0g</title>
		<link>http://consoleart.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://consoleart.wordpress.com/osd.xml" title="C0ns0l3art&#039;s Bl0g" />
	<atom:link rel='hub' href='http://consoleart.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Azure &#8211; Remote desktop &#8211; Not a genuine copy of windows</title>
		<link>http://consoleart.wordpress.com/2011/04/28/azure-remote-desktop-not-a-genuine-copy-of-windows/</link>
		<comments>http://consoleart.wordpress.com/2011/04/28/azure-remote-desktop-not-a-genuine-copy-of-windows/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 10:38:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2011/04/28/azure-remote-desktop-not-a-genuine-copy-of-windows</guid>
		<description><![CDATA[I have enabled RD option on my Web role instance and logged into the server using Remote Desktop. Was surprised to see the message &#8220;this copy of windows is not genuine&#8221; Not sure why this message was been displayed on the data center server<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=154&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div dir="ltr" style="text-align:left;">I have enabled RD option on my Web role instance and logged into the server using Remote Desktop. Was surprised to see the message &#8220;this copy of windows is not genuine&#8221; Not sure why this message was been displayed on the data center server</p>
<div class="separator" style="clear:both;text-align:center;"></div>
<div class="separator" style="clear:both;text-align:center;"></div>
<p>
<div class="separator" style="clear:both;text-align:center;"><a href="http://consoleart.files.wordpress.com/2011/04/azure-rd-notagenuinecopy.png?w=300" style="margin-left:1em;margin-right:1em;"><img border="0" src="http://consoleart.files.wordpress.com/2011/04/azure-rd-notagenuinecopy.png?w=300" /></a></div>
<p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=154&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2011/04/28/azure-remote-desktop-not-a-genuine-copy-of-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>

		<media:content url="http://consoleart.files.wordpress.com/2011/04/azure-rd-notagenuinecopy.png?w=300" medium="image" />
	</item>
		<item>
		<title>Alert dialog</title>
		<link>http://consoleart.wordpress.com/2010/12/27/alert-dialog/</link>
		<comments>http://consoleart.wordpress.com/2010/12/27/alert-dialog/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 18:09:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[alertdialog]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/12/27/alert-dialog</guid>
		<description><![CDATA[I have been trying to show a alert dialog for one of my projects, so here is how you do it&#8230; package ; import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button; public class Registration extends Activity {    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.registration);//this is the XML file that you will using for your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=155&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been trying to show a alert dialog for one of my projects, so here is how you do it&#8230;</p>
<p>package ;</p>
<p>import android.app.Activity;<br />import android.app.AlertDialog;<br />import android.content.Context;<br />import android.content.DialogInterface;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.view.View.OnClickListener;<br />import android.widget.Button;</p>
<p>public class Registration extends Activity {<br />    public void onCreate(Bundle savedInstanceState) {<br />        super.onCreate(savedInstanceState);<br />        setContentView(R.layout.registration);//this is the XML file that you will using for your layout</p>
<p>        Button button = (Button)findViewById(R.id.ok);</p>
<p>        button.setOnClickListener(clicklistener);</p>
<p>        <br />        <br />    }<br />    public OnClickListener clicklistener = new OnClickListener() {<br />        public void onClick(View v) {<br />          // do something when the button is clicked<br />            AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());<br />            builder.setMessage(&#8220;Are you sure you want to exit?&#8221;)<br />                   .setCancelable(false)<br />                   .setPositiveButton(&#8220;Yes&#8221;, new DialogInterface.OnClickListener() {<br />                       public void onClick(DialogInterface dialog, int id) {<br />                                                   }<br />                   })<br />                   .setNegativeButton(&#8220;No&#8221;, new DialogInterface.OnClickListener() {<br />                       public void onClick(DialogInterface dialog, int id) {<br />                                               }<br />                   });<br />            builder.create();<br />            builder.show();<br />        }<br />    };</p>
<p>    <br />}</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=155&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/12/27/alert-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Android SDK &#8211; Emulator &#8211; on MAC</title>
		<link>http://consoleart.wordpress.com/2010/12/09/android-sdk-emulator-on-mac/</link>
		<comments>http://consoleart.wordpress.com/2010/12/09/android-sdk-emulator-on-mac/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 16:31:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[APK]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/12/09/android-sdk-emulator-on-mac</guid>
		<description><![CDATA[Ok, now that i have my first app built in android, i want to give it to my client for a demo who does not have a android PAD, (or yet to have one)&#8230;so they have to use the emulator which comes with android SDK to install the APP and show it running like its [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=156&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ok, now that i have my first app built in android, i want to give it to my client for a demo who does not have a android PAD, (or yet to have one)&#8230;so they have to use the emulator which comes with android SDK to install the APP and show it running like its an android device&#8230;.<br />the steps are pretty much simple<br />(please note you dont need Eclipse or any plugin to just run a APK (android package), &#8211; they are needed only for developers to debug and stuff)&#8230;</p>
<p>1) install android SDK(google has enuf details for it)<br />2) RUN the emulator so taht it starts up and ready to install your app<br />3) copy the APK file to a particular folder (say Desktop)<br />4) open up the terminal and navigate to the andoird SDK folder</p>
<p>$ cd ./android<br />$ cd platform-tools<br />your current working directory would be the platform-tools which contains a file called ADB.exe which will install the APK to the android emulator device&#8230;<br />execute the command<br />$ ./adb install &#8220;APK file name&#8221;</p>
<p>it will show some messages like installing etc., and has to finally say SUCCESS&#8230;</p>
<p>go to the emulator and open up the menu by clicking the android menu button (its the little dots stacked at the bottom of the page and not the button labelled &#8220;MENU&#8221; on the emulator)</p>
<p>you must then see your app being displayed as an icon&#8230;.</p>
<p>happy androiding&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=156&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/12/09/android-sdk-emulator-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Install APK file from command Prompt</title>
		<link>http://consoleart.wordpress.com/2010/12/08/install-apk-file-from-command-prompt/</link>
		<comments>http://consoleart.wordpress.com/2010/12/08/install-apk-file-from-command-prompt/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 15:11:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/12/08/install-apk-file-from-command-prompt</guid>
		<description><![CDATA[ I have now finished with my POC and want to install it in my android emulator outside of Eclipse. Here are the steps Execute the emulator so that it starts and is ready to install new programs.(you need to run the emulator.exe under the android SDK\Tools folder)1) copy the APK file (which will under /bin [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=159&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> I have now finished with my POC and want to install it in my android emulator outside of Eclipse.</p>
<p>Here are the steps</p>
<p>Execute the emulator so that it starts and is ready to install new programs.<br />(you need to run the emulator.exe under the android SDK\Tools folder)<br />1) copy the APK file (which will under /bin directory) to &#8220;C:\myProject.apk&#8221; (this step is really not needed, but its just a failsafe method)</p>
<p>2) open the command prompt (in your PC and not in the emulator) and type</p>
<p>abd install c:\myProject.apx</p>
<p>this will install the APK file in the emulator</p>
<p>3) If you are getting &#8220;command not found&#8221; &#8211; navigate to the Android SDK/Tools folder<br />cd x:/androidsdkfolder/tools<br />and run command again&#8230;..</p>
<p>happy androiding !!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/159/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/159/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/159/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=159&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/12/08/install-apk-file-from-command-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Development &#8211; with Android SDK and Eclipse</title>
		<link>http://consoleart.wordpress.com/2010/12/07/android-development-with-android-sdk-and-eclipse/</link>
		<comments>http://consoleart.wordpress.com/2010/12/07/android-development-with-android-sdk-and-eclipse/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 06:09:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/12/07/android-development-with-android-sdk-and-eclipse</guid>
		<description><![CDATA[Working with Android SDK with Eclipse. So now that i started doing my first android PAD project for one of my clients. We need to submit a POC which will showcase a work flow. A login screen, a screen with tab controls, a grid view with menu and a table layout with details. Before I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=160&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Working with Android SDK with Eclipse.</p>
<p>So now that i started doing my first android PAD project for one of my clients. We need to submit a POC which will showcase a work flow. A login screen, a screen with tab controls, a grid view with menu and a table layout with details.</p>
<p>Before I start the work i need to set my DEV environment. Being a C# developer for most of my life I am taking baby steps towards Java programming and that too with android. Interesting&#8230;.</p>
<p>What we need ?<br />1) Android SDK<br />2) Eclipse<br />3) ADT Plugin for Java.</p>
<p>There is an excellent tutorial at the android developer community for setting up the environment, but I found my self stuck at a couple of places&#8230;.so thought i should blog it myself&#8230;</p>
<p>1) Download the SDK from the location<br />http://dl.google.com/android/android-sdk_r08-windows.zip</p>
<ul>
<li>Unzip the contents of the SDK (I choose to unzip the contents inside Program Files\AndroidSDK directory, so that I dont accidentally delete the contents by placing it somewhere else)</li>
<li>and execute the SDK Manager.exe, it will start downloading the platform(which takes around 2 hrs with a 150 KBPS actual download speed)</li>
<li> after installation the SDK folder will be populated with the platform details, you can see the various supported platforms inside the PLATFORM folder.</li>
</ul>
<p>2) Download and Install Eclipse latest release &#8211; Eclipse website has detailed information on the installation. http://www.eclipse.org/downloads/ (download the one which says &#8220;Eclipse IDE for Java Developers)</p>
<p>After successful installation <br />Go to  Help &#8211;&gt; Software updates &#8211;&gt;(or Help Install New Software in Eclipse &#8211; Gallileo) add the site &#8220;https://dl-ssl.google.com/android/eclipse/&#8221; to the updates directory and click the ADD software button, it will list down the details available to install and click NEXT &amp; finish the installation&#8230;it will install the ADT plugin. </p>
<p>3) After installation the menu Android will appear in Window &#8211;&gt; Preference menu, Navigate to it and Click the Browse button and set the path of the SDK folder &#8211;&gt; click ok and apply &#8211;&gt; restart Eclipse.</p>
<p>4) create a new AVD image &#8211; This is the Emulator that will open when you execute your android APP<br />select window &#8211;&gt; Android SDK and AVD Manager and create a new device. Make sure that you choose the right version for your project.</p>
<p>Now we are ready to start a project<br />After create a new android project , set the target of Run configuration (Run&#8211;&gt;run configuration &#8211;&gt; android &#8211;&gt; new configuration) to the AVD you just created.</p>
<p>when you RUN you app, the Emulator will start and you are ready to roll on&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=160&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/12/07/android-development-with-android-sdk-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding bat &#8211; solutions &#8211; solution</title>
		<link>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-solution/</link>
		<comments>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-solution/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 06:50:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[codingBat]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[URLLIB]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-solution</guid>
		<description><![CDATA[Given 3 int values, a b c, return their sum. However, if any of the values is a teen &#8212; in the range 13..19 inclusive &#8212; then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper &#8220;def fix_teen(n):&#8221;that takes in an int value and returns [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=161&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 3 int values, a b c, return their sum. However, if any of the values is a teen &#8212; in the range 13..19 inclusive &#8212; then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper &#8220;def fix_teen(n):&#8221;that takes in an int value and returns that value fixed for the teen rule. In this way, you avoid repeating the teen code 3 times (i.e. &#8220;decomposition&#8221;). Define the helper below and at the same indent level as the main no_teen_sum().</p>
<p>no_teen_sum(1, 2, 3) → 6<br />no_teen_sum(2, 13, 1) → 3<br />no_teen_sum(2, 1, 14) → 3&#8230;Save, Compile, Run<br />
<form name="codeform">
<pre style="border:2px solid gray;">def fix_teen(num):  if num &gt;12 and num &lt;20 and not num ==15 and not num ==16:    return 0  else:    return numdef no_teen_sum(a, b, c):  return fix_teen(a) + fix_teen(b)+fix_teen(c)</pre>
</form>
</td>
</tr>
</tbody>
<p> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p100347.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </table>
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 3 int values, a b c, return their sum. However, if any of the values is a teen &#8212; in the range 13..19 inclusive &#8212; then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper &#8220;def fix_teen(n):&#8221;that takes in an int value and returns that value fixed for the teen rule. In this way, you avoid repeating the teen code 3 times (i.e. &#8220;decomposition&#8221;). Define the helper below and at the same indent level as the main no_teen_sum().</p>
<p>no_teen_sum(1, 2, 3) → 6<br />no_teen_sum(2, 13, 1) → 3<br />no_teen_sum(2, 1, 14) → 3&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def fix_teen(num):  if num &gt;12 and num &lt;20 and not num ==15 and not num ==16:    return 0  else:    return numdef no_teen_sum(a, b, c):  return fix_teen(a) + fix_teen(b)+fix_teen(c)</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p100958.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">The number 6 is a truly great number. Given two int values, a and b, return True if either one is 6. Or if their sum or difference is 6. Note: the function abs(num) computes the absolute value of a number.</p>
<p>love6(6, 4) → True<br />love6(4, 5) → False<br />love6(1, 5) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def love6(a, b):  return a ==6 or b == 6 or a+b ==6 or abs(a-b) == 6  </pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p107010.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string of even length, return the first half. So the string &#8220;WooHoo&#8221; yields &#8220;Woo&#8221;.</p>
<p>first_half(&#8216;WooHoo&#8217;) → &#8216;Woo&#8217;<br />first_half(&#8216;HelloThere&#8217;) → &#8216;Hello&#8217;<br />first_half(&#8216;abcdef&#8217;) → &#8216;abc&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def first_half(str):  return str[0:len(str)/2]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p107863.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count.</p>
<p>lucky_sum(1, 2, 3) → 6<br />lucky_sum(1, 2, 13) → 3<br />lucky_sum(1, 13, 3) → 1&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def lucky_sum(a, b, c):  sum = 0  if a == 13:    return 0  elif b == 13:    return a  elif c==13:    return a+b  else:    return a+b+c</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p108886.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 7 (every 6 will be followed by at least one 7). Return 0 for no numbers.</p>
<p>sum67([1, 2, 2]) → 5<br />sum67([1, 2, 2, 6, 99, 99, 7]) → 5<br />sum67([1, 1, 6, 7, 2]) → 4&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def sum67(nums):  if len(nums) == 0:    return 0    sum = 0  sum671 = 0    for num in nums:    if num == 6 or not sum671 == 0:      sum671 += num    if num ==7  and not sum671 == 0:      sum-=sum671      sum671=0        sum +=num      return sum</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p110166.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return True if one of the first 4 elements in the array is a 9. The array length may be less than 4.</p>
<p>array_front9([1, 2, 9, 3, 4]) → True<br />array_front9([1, 2, 3, 4, 9]) → False<br />array_front9([1, 2, 3, 4, 5]) → False&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def array_front9(nums):%0a  # First figure the end for the loop%0a  end = len(nums)%0a  if end %26gt; 4:%0a    end = 4%0a  %0a  for i in range(end):  # loop over index [0, 1, 2, 3]%0a    if nums[i] == 9:%0a      return True%0a  return False" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def array_front9(nums):

  loopcount = len(nums)  if loopcount &gt; 4:    loopcount = 4  for i in range(loopcount):    if nums[i] == 9:      return True    return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p113152.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a new string made of every other char starting with the first, so &#8220;Hello&#8221; yields &#8220;Hlo&#8221;.</p>
<p>string_bits(&#8216;Hello&#8217;) → &#8216;Hlo&#8217;<br />string_bits(&#8216;Hi&#8217;) → &#8216;H&#8217;<br />string_bits(&#8216;Heeololeo&#8217;) → &#8216;Hello&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def string_bits(str):%0a  result = %26quot;%26quot;%0a  # Many ways to do this. This uses the standard loop of i on every char,%0a  # and inside the loop skips the odd index values.%0a  for i in range(len(str)):%0a    if i %25 2 == 0:%0a      result = result + str[i]%0a  return result" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def string_bits(str):  ret = ''  for i in range(len(str)):    if (i+1) %2 == 1:      ret += str[i]

  return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p113659.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return an int array length 3 containing the first 3 digits of pi, {3, 1, 4}.</p>
<p>make_pi() → [3, 1, 4]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_pi():   return [3,1,4]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p115413.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string name, e.g. &#8220;Bob&#8221;, return a greeting of the form &#8220;Hello Bob!&#8221;.</p>
<p>hello_name(&#8216;Bob&#8217;) → &#8216;Hello Bob!&#8217;<br />hello_name(&#8216;Alice&#8217;) → &#8216;Hello Alice!&#8217;<br />hello_name(&#8216;X&#8217;) → &#8216;Hello X!&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def hello_name(name):  return "Hello " + name + "!"</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p116620.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 ints, a and b, return their sum. However, sums in the range 10..19 inclusive, are forbidden, so in that case just return 20.</p>
<p>sorta_sum(3, 4) → 7<br />sorta_sum(9, 4) → 20<br />sorta_sum(10, 11) → 21&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def sorta_sum(a, b):  sum = a+b  if sum &gt;=10 and sum&lt;20:    return 20  else:    return sum</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p118366.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a non-empty string like &#8220;Code&#8221; return a string like &#8220;CCoCodCode&#8221;.</p>
<p>string_splosion(&#8216;Code&#8217;) → &#8216;CCoCodCode&#8217;<br />string_splosion(&#8216;abc&#8217;) → &#8216;aababc&#8217;<br />string_splosion(&#8216;ab&#8217;) → &#8216;aab&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def string_splosion(str):%0a  result = %26quot;%26quot;%0a  # On each iteration, add the substring of the chars 0..i%0a  for i in range(len(str)):%0a    result = result + str[:i+1]%0a  return result" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def string_splosion(str):  ret = ''  for i in range(len(str)+1):    ret += str[0:i]      return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p118406.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">We want to make a row of bricks that is <b>goal</b> inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.</p>
<p>make_bricks(3, 1, 8) → True<br />make_bricks(3, 1, 9) → False<br />make_bricks(3, 2, 10) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_bricks(small, big, goal):  if big ==0:    return small &gt;=goal  elif big*5 == goal:    return True  else:    rem = 0    if goal &gt; big*5:      rem = goal - (big*5)    else:      rem = goal % 5    return small &gt;= rem </pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p119308.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return True if the array contains a 2 next to a 2 somewhere.</p>
<p>has22([1, 2, 2]) → True<br />has22([1, 2, 1, 2]) → False<br />has22([2, 1, 2]) → False&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def has22(nums):  for num in range(len(nums)-1):    if nums[num] == 2 and nums[num+1] == 2:      return True    return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p119867.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a day of the week encoded as 0=Sun, 1=Mon, 2=Tue, &#8230;6=Sat, and a boolean indicating if we are on vacation, return a string of the form &#8220;7:00&#8243; indicating when the alarm clock should ring. Weekdays, the alarm should be &#8220;7:00&#8243; and on the weekend it should be &#8220;10:00&#8243;. Unless we are on vacation &#8212; then on weekdays it should be &#8220;10:00&#8243; and weekends it should be &#8220;off&#8221;.</p>
<p>alarm_clock(1, False) → &#8217;7:00&#8242;<br />alarm_clock(5, False) → &#8217;7:00&#8242;<br />alarm_clock(0, False) → &#8217;10:00&#8242;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def alarm_clock(day, vacation):  #weekend calculation  if vacation:    weekday = "10:00"    weekend = "off"  else:    weekday = "7:00"    weekend = "10:00"          if (day == 0 or day ==6):    return weekend  else:    return weekday</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p120546.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">We have two monkeys, a and b, and the parameters a_smile and b_smile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return True if we are in trouble.</p>
<p>monkey_trouble(True, True) → True<br />monkey_trouble(False, False) → True<br />monkey_trouble(True, False) → False&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def monkey_trouble(a_smile, b_smile):%0a  if a_smile and b_smile:%0a    return True%0a  if not a_smile and not b_smile:%0a    return True%0a  return False%0a  ## The above can be shortened to:%0a  ##   return ((a_smile and b_smile) or (not a_smile and not b_smile))%0a  ## Or this very short version (think about how this is the same as the above)%0a  ##   return (a_smile == b_smile)" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def monkey_trouble(a_smile, b_smile):  if a_smile and b_smile:    return True  if not a_smile and not b_smile:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p124676.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an int n, return True if it is within 10 of 100 or 200. Note: abs(num) computes the absolute value of a number.</p>
<p>near_hundred(93) → True<br />near_hundred(90) → True<br />near_hundred(89) → False&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def near_hundred(n):%0a  return ((abs(100 - n) %26lt;= 10) or (abs(200 - n) %26lt;= 10))" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def find(num,n):  dif = abs(num-n)  if dif &lt;= 10:    return True    return False  def near_hundred(n):  ret = find(100,n)  if not ret:      ret = find(200,n)    return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p124806.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return a new array length 2 containing the first and last elements from the original array. The original array will be length 1 or more.</p>
<p>make_ends([1, 2, 3]) → [1, 3]<br />make_ends([1, 2, 3, 4]) → [1, 4]<br />make_ends([7, 4, 6, 2]) → [7, 2]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_ends(nums):  return [nums[0],nums[-1]]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p124984.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 ints, a and b, return True if one if them is 10 or if their sum is 10.</p>
<p>makes10(9, 10) → True<br />makes10(9, 9) → False<br />makes10(1, 9) → True&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def makes10(a, b):%0a  return (a == 10 or b == 10 or a+b == 10)" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def makes10(a, b):  if a == 10 or b == 10 or a+b ==10:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p126968.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return the &#8220;centered&#8221; average of an array of ints, which we&#8217;ll say is the mean average of the values, except not counting the largest and smallest values in the array. Use int division to produce the final average. You may assume that the array is length 3 or more.</p>
<p>centered_average([1, 2, 3, 4, 100]) → 3<br />centered_average([1, 1, 5, 5, 10, 8, 7]) → 5<br />centered_average([-10, -4, -2, -4, -2, 0]) → -3&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def centered_average(nums):  sortednums = sorted(nums)  sortednums.remove(sortednums[0])  sortednums.remove(sortednums[-1])  sum = 0  for num in range(len(sortednums)):    sum+=sortednums[num]  return sum/len(sortednums)</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p127703.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 strings, return their concatenation, except omit the first char of each. The strings will be at least length 1.</p>
<p>non_start(&#8216;Hello&#8217;, &#8216;There&#8217;) → &#8216;ellohere&#8217;<br />non_start(&#8216;java&#8217;, &#8216;code&#8217;) → &#8216;avaode&#8217;<br />non_start(&#8216;shotl&#8217;, &#8216;java&#8217;) → &#8216;hotlava&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def non_start(a, b):  return a[1:]+b[1:]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p129125.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">You and your date are trying to get a table at a restaurant. The parameter &#8220;you&#8221; is the stylishness of your clothes, in the range 0..10, and &#8220;date&#8221; is the stylishness of your date&#8217;s clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very stylish, 8 or more, then the result is 2 (yes). With the exception that if either of you has style of 2 or less, then the result is 0 (no). Otherwise the result is 1 (maybe).</p>
<p>date_fashion(5, 10) → 2<br />date_fashion(5, 2) → 0<br />date_fashion(5, 5) → 1&#8230;Save, Compile, Run          <span id="hint">&lt;button onclick=&quot;document.getElementById(&quot;hint&quot;).innerHTML=unescape(&quot;Hint: One solution uses the pattern
<pre>if xxx:%0a  return 0%0aelif yyy:%0a  return 2%0aelse:%0a  return 1%0a</pre>
<p>  where xxx and yyy compute with %26lt;=, %26gt;= if the you/date numbers get that result. The order of the if statements is significant &#8212; the 0 result case takes precedence over the other cases, so that if statement comes first.&#8221;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Hint</button></span>
<pre style="border:2px solid gray;">def date_fashion(you, date):  if you &lt;=2 or date &lt;=2:    return 0  if you &gt;=8 or date &gt;=8:    return 2    return 1</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p129981.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an &#8220;out&#8221; string length 4, such as &#8220;&lt;&gt;&#8221;, and a word, return a new string where the word is in the middle of the out string, e.g. &#8220;&lt;&gt;&#8221;. </p>
<p>make_out_word(&#8216;&lt;&gt;&#8217;, &#8216;Yay&#8217;) → &#8216;&lt;&gt;&#8217;<br />make_out_word(&#8216;&lt;&gt;&#8217;, &#8216;WooHoo&#8217;) → &#8216;&lt;&gt;&#8217;<br />make_out_word(&#8216;[[]]&#8217;, &#8216;word&#8217;) → &#8216;[[word]]&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_out_word(out, word):  s = "{0}{1}{2}".format(out[0:2],word,out[2:])  return s</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p132290.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">The web is built with HTML strings like &#8220;<i>Yay</i>&#8221; which draws Yay as italic text. In this example, the &#8220;i&#8221; tag makes <i> and </i> which surround the word &#8220;Yay&#8221;. Given tag and word strings, create the HTML string with tags around the word, e.g. &#8220;<i>Yay</i>&#8220;.</p>
<p>make_tags(&#8216;i&#8217;, &#8216;Yay&#8217;) → &#8216;<i>Yay</i>&#8216;<br />make_tags(&#8216;i&#8217;, &#8216;Hello&#8217;) → &#8216;<i>Hello</i>&#8216;<br />make_tags(&#8216;cite&#8217;, &#8216;Yay&#8217;) → &#8216;<cite>Yay</cite>&#8216;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_tags(tag, word):  return "{1}".format(tag,word)  </pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p135290.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints length 3, figure out which is larger between the first and last elements in the array, and set all the other elements to be that value. Return the changed array.</p>
<p>max_end3([1, 2, 3]) → [3, 3, 3]<br />max_end3([11, 5, 9]) → [11, 11, 11]<br />max_end3([2, 11, 3]) → [3, 3, 3]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def max_end3(nums):  max1 = max(nums[0],nums[-1])  return [max1,max1,max1]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p135815.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature and a boolean is_summer, return True if the squirrels play and False otherwise.</p>
<p>squirrel_play(70, False) → True<br />squirrel_play(95, False) → False<br />squirrel_play(95, True) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def squirrel_play(temp, is_summer):  upper_limit = 90  if is_summer == True:    upper_limit = 100    return temp &gt;= 60 and temp &lt;=upper_limit</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p137202.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the result is 1. If speed is 81 or more, the result is 2. Unless it is your birthday &#8212; on that day, your speed can be 5 higher in all cases.</p>
<p>caught_speeding(60, False) → 0<br />caught_speeding(65, False) → 1<br />caught_speeding(65, True) → 0&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def caught_speeding(speed, is_birthday):  limit_ext = 0  if is_birthday:    limit_ext = 5    if speed &lt;= 60+limit_ext:    return 0  elif speed &lt;= 80 +limit_ext:    return 1  else:    return 2</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p138533.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a version without the first and last char, so &#8220;Hello&#8221; yields &#8220;ell&#8221;. The string length will be at least 2.</p>
<p>without_end(&#8216;Hello&#8217;) → &#8216;ell&#8217;<br />without_end(&#8216;java&#8217;) → &#8216;av&#8217;<br />without_end(&#8216;coding&#8217;) → &#8216;odin&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def without_end(str):  return str[1:-1]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p141905.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given two int values, return their sum. Unless the two values are the same, then return double their sum.</p>
<p>sum_double(1, 2) → 3<br />sum_double(3, 2) → 5<br />sum_double(2, 2) → 8&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def sum_double(a, b):%0a  # Store the sum in a local variable%0a  sum = a + b%0a  %0a  # Double it if a and b are the same%0a  if a == b:%0a    sum = sum * 2%0a  return sum" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def sum_double(a, b):  sum = a + b  if a == b:    return sum * 2    return sum</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p143951.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 3 int values, a b c, return their sum. However, if one of the values is the same as another of the values, it does not count towards the sum.</p>
<p>lone_sum(1, 2, 3) → 6<br />lone_sum(3, 2, 3) → 2<br />lone_sum(3, 3, 3) → 0&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def lone_sum(a, b, c):  list = [a,b,c]  sorted_list = sorted(list)  sum = 0  if not sorted_list[0] == sorted_list[1]:    sum += sorted_list[0] + sorted_list[1]    if not sorted_list[1] == sorted_list[2]:    sum += sorted_list[2]    elif not list == sorted_list:    sum -= sorted_list[2]    return sum</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p145834.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so &#8220;hixxxhi&#8221; yields 1 (we won&#8217;t count the end substring).</p>
<p>last2(&#8216;hixxhi&#8217;) → 1<br />last2(&#8216;xaxxaxaxx&#8217;) → 1<br />last2(&#8216;axxxaaxx&#8217;) → 2&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def last2(str):%0a  # Screen out too-short string case.%0a  if len(str) %26lt; 2:%0a    return 0%0a  %0a  # last 2 chars, can be written as str[-2:]%0a  last2 = str[len(str)-2:]%0a  count = 0%0a  %0a  # Check each substring length 2 starting at i%0a  for i in range(len(str)-2):%0a    sub = str[i:i+2]%0a    if sub == last2:%0a      count = count + 1%0a%0a  return count" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def last2(str):  if len(str) &lt; 2:    return 0    last2 = str[len(str)-2:]  count = 0    for i in range(len(str)-2):    sub = str[i:i+2]    if sub == last2:      count = count + 1

  return count</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p147755.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 arrays of ints, a and b, return True if they have the same first element or they have the same last element. Both arrays will be length 1 or more.</p>
<p>common_end([1, 2, 3], [7, 3]) → True<br />common_end([1, 2, 3], [7, 3, 2]) → False<br />common_end([1, 2, 3], [1, 3]) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def common_end(a, b):  if a[0] == b[0] or a[-1] == b[-1]:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p147920.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, we&#8217;ll say that the front is the first 3 chars of the string. If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front.</p>
<p>front3(&#8216;Java&#8217;) → &#8216;JavJavJav&#8217;<br />front3(&#8216;Chocolate&#8217;) → &#8216;ChoChoCho&#8217;<br />front3(&#8216;abc&#8217;) → &#8216;abcabcabc&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def front3(str):%0a  # Figure the end of the front%0a  front_end = 3%0a  if len(str) %26lt; front_end:%0a    front_end = len(str)%0a  front = str[:front_end]%0a  return front + front + front %0a  %0a  # Could omit the if logic, and write simply front = str[:3]%0a  # since the slice is silent about out-of-bounds conditions." + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def front3(str):  front = str  if len(str) &gt;= 3:    front = str[0:3]  ret = ''  for i in range(1,4):    ret = ret + front    return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p148661.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints length 3, return an array with the elements &#8220;rotated left&#8221; so {1, 2, 3} yields {2, 3, 1}.</p>
<p>rotate_left3([1, 2, 3]) → [2, 3, 1]<br />rotate_left3([5, 11, 9]) → [11, 9, 5]<br />rotate_left3([7, 0, 0]) → [0, 0, 7]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def rotate_left3(nums):  nums.append(nums[0])  nums.remove(nums[0])  return nums</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p148853.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a new string made of 3 copies of the last 2 chars of the original string. The string length will be at least 2.</p>
<p>extra_end(&#8216;Hello&#8217;) → &#8216;lololo&#8217;<br />extra_end(&#8216;ab&#8217;) → &#8216;ababab&#8217;<br />extra_end(&#8216;Hi&#8217;) → &#8216;HiHiHi&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def extra_end(str):  s = str[-2:]  return 3*s</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p149391.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return True if the given string contains an appearance of &#8220;xyz&#8221; where the xyz is not directly preceeded by a period (.). So &#8220;xxyz&#8221; counts but &#8220;x.xyz&#8221; does not.</p>
<p>xyz_there(&#8216;abcxyz&#8217;) → True<br />xyz_there(&#8216;abc.xyz&#8217;) → False<br />xyz_there(&#8216;xyz.abc&#8217;) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def xyz_there(str):  str = str.replace('.xyz','')  index = str.find('xyz')    return index &gt;= 0 and not str[index-1] == "."</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p149524.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a non-empty string and an int n, return a new string where the char at index n has been removed. The value of n will be a valid index of a char in the original string (i.e. n will be in the range 0..len(str)-1 inclusive).</p>
<p>missing_char(&#8216;kitten&#8217;, 1) → &#8216;ktten&#8217;<br />missing_char(&#8216;kitten&#8217;, 0) → &#8216;itten&#8217;<br />missing_char(&#8216;kitten&#8217;, 4) → &#8216;kittn&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def missing_char(str, n):%0a  front = str[:n]   # up to but not including n%0a  back = str[n+1:]  # n+1 through end of string%0a  return front + back" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def missing_char(str, n):  if n &gt; len(str):    return str

  return str[:n] + str[n+1:]   </pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p153599.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a new string where the first and last chars have been exchanged.</p>
<p>front_back(&#8216;code&#8217;) → &#8216;eodc&#8217;<br />front_back(&#8216;a&#8217;) → &#8216;a&#8217;<br />front_back(&#8216;ab&#8217;) → &#8216;ba&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def front_back(str):%0a  if len(str) %26lt;= 1:%0a    return str%0a  %0a  mid = str[1:len(str)-1]  # can be written as str[1:-1]%0a  %0a  # last + mid + first%0a  return str[len(str)-1] + mid + str[0]" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def front_back(str):  if len(str) &lt;=1:     return str  s = str[-1] + str[1:len(str)-1] + str[0]  return s</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p158497.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a number n, return True if n is in the range 1..10, inclusive. Unless &#8220;outsideMode&#8221; is True, in which case return True if the number is less or equal to 1, or greater or equal to 10.</p>
<p>in1to10(5, False) → True<br />in1to10(11, False) → False<br />in1to10(11, True) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def in1to10(n, outside_mode):  a=n  if outside_mode:    if a =10:      return True    else:      return False  else:    if a &gt;=1 and a &lt;=10:      return True    else:      return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p160533.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given three ints, a b c, return True if one of b or c is &#8220;close&#8221; (differing from a by at most 1), while the other is &#8220;far&#8221;, differing from both other values by 2 or more. Note: abs(num) computes the absolute value of a number.</p>
<p>close_far(1, 2, 10) → True<br />close_far(1, 2, 3) → False<br />close_far(4, 1, 3) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def close_far(a, b, c):  abs_b = abs(b-a)  abs_c = abs(c-a)  abs_c2 = abs(c-b)  if abs_b &lt;=1:    return abs_c &gt;=2 and abs_c2 &gt;=2  elif abs_c &lt;=1:    return abs_b &gt;=2 and abs_c2 &gt;=2  else:    return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p160545.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a &#8220;rotated left 2&#8243; version where the first 2 chars are moved to the end. The string length will be at least 2.</p>
<p>left2(&#8216;Hello&#8217;) → &#8216;lloHe&#8217;<br />left2(&#8216;java&#8217;) → &#8216;vaja&#8217;<br />left2(&#8216;Hi&#8217;) → &#8216;Hi&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def left2(str):  return str[2:] + str[0:2]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p162058.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 int values, return True if one is negative and one is positive. Unless the parameter &#8220;negative&#8221; is True, then they both must be negative.</p>
<p>pos_neg(1, -1, False) → True<br />pos_neg(-1, 1, False) → True<br />pos_neg(1, 1, False) → False&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def pos_neg(a, b, negative):%0a  if negative:%0a    return (a %26lt; 0 and b %26lt; 0)%0a  else:%0a    return ((a %26lt; 0 and b %26gt; 0) or (a %26gt; 0 and b %26lt; 0))" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def pos_neg(a, b, negative):  if negative and a&lt;0 and b&lt;0:    return True  elif not negative and ((a 0) or (a&gt;0 and b &lt; 0)):    return True    return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p164876.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return True if the string &#8220;cat&#8221; and &#8220;dog&#8221; appear the same number of times in the given string.</p>
<p>cat_dog(&#8216;catdog&#8217;) → True<br />cat_dog(&#8216;catcat&#8217;) → False<br />cat_dog(&#8217;1cat1cadodog&#8217;) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def cat_dog(str):  catcount = 0  dogcount = 0  for i in range(len(str)-2):    if str[i:i+3] =='cat':      catcount+=1    if str[i:i+3] =='dog':      dogcount+=1

  return catcount == dogcount</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p165097.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string and a non-negative int n, we&#8217;ll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front;</p>
<p>front_times(&#8216;Chocolate&#8217;, 2) → &#8216;ChoCho&#8217;<br />front_times(&#8216;Chocolate&#8217;, 3) → &#8216;ChoChoCho&#8217;<br />front_times(&#8216;Abc&#8217;, 3) → &#8216;AbcAbcAbc&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def front_times(str, n):%0a  front_len = 3%0a  if front_len %26gt; len(str):%0a    front_len = len(str)%0a  front = str[:front_len]%0a  %0a  result = %26quot;%26quot;%0a  for i in range(n):%0a    result = result + front%0a  return result" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def front_times(str, n):  ret = ''  front = str[0:3]  for i in range(n):    ret += front      return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p165321.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a non-negative number &#8220;num&#8221;, return True if num is within 2 of a multiple of 10. Note: (a % b) is the remainder of dividing a by b, so (7 % 5) is 2.</p>
<p>near_ten(12) → True<br />near_ten(17) → False<br />near_ten(19) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def near_ten(num):  a =  num % 10  return a =8</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p166170.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return the number of 9&#8242;s in the array.</p>
<p>array_count9([1, 2, 9]) → 1<br />array_count9([1, 9, 9]) → 2<br />array_count9([1, 9, 9, 3, 9]) → 3&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def array_count9(nums):%0a  count = 0%0a  # Standard loop to look at each value%0a  for num in nums:%0a    if num == 9:%0a      count = count + 1%0a%0a  return count" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def array_count9(nums):  ret = 0  for i in range(len(nums)):    if nums[i] == 9:      ret+=1    return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p166884.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">We have a loud talking parrot. The &#8220;hour&#8221; parameter is the current hour time in the range 0..23. We are in trouble if the parrot is talking and the hour is before 7 or after 20. Return True if we are in trouble.</p>
<p>parrot_trouble(True, 6) → True<br />parrot_trouble(True, 7) → False<br />parrot_trouble(False, 6) → False&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def parrot_trouble(talking, hour):%0a  return (talking and (hour %26lt; 7 or hour %26gt; 20))%0a  # Need extra parenthesis around the or clause%0a  # since and binds more tightly than or.%0a  # and is like arithmetic *, or is like arithmetic +" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def parrot_trouble(talking, hour):  if talking and (hour  20):    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p167246.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return the number of times that the string &#8220;hi&#8221; appears anywhere in the given string. </p>
<p>count_hi(&#8216;abc hi ho&#8217;) → 1<br />count_hi(&#8216;ABChi hi&#8217;) → 2<br />count_hi(&#8216;hihi&#8217;) → 2&#8230;Save, Compile, Run          <span id="hint"><button>Show Hint</button></span>
<pre style="border:2px solid gray;">def count_hi(str):  count = 0  for i in range(len(str)-1):    if str[i:i+2] =='hi' and not i == len(str):      count+=1    return count</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p170842.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a string where for every char in the original, there are two chars.</p>
<p>double_char(&#8216;The&#8217;) → &#8216;TThhee&#8217;<br />double_char(&#8216;AAbb&#8217;) → &#8216;AAAAbbbb&#8217;<br />double_char(&#8216;Hi-There&#8217;) → &#8216;HHii&#8211;TThheerree&#8217;&#8230;Save, Compile, Run          <span id="hint"><button>Show Hint</button></span>
<pre style="border:2px solid gray;">def double_char(str):  finalstr =''  for s in str:    finalstr += 2*s  return finalstr</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p171011.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 int arrays, a and b, each length 3, return a new array length 2 containing their middle elements.</p>
<p>middle_way([1, 2, 3], [4, 5, 6]) → [2, 5]<br />middle_way([7, 7, 7], [3, 8, 0]) → [7, 8]<br />middle_way([5, 2, 9], [1, 4, 5]) → [2, 4]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def middle_way(a, b):  return [a[1],b[1]]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p173401.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we&#8217;re on vacation. Return True if we sleep in.</p>
<p>sleep_in(False, False) → True<br />sleep_in(True, False) → False<br />sleep_in(False, True) → True&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def sleep_in(weekday, vacation):%0a  if not weekday or vacation:%0a    return True%0a  else:%0a    return False%0a  # This can be shortened to: return(not weekday or vacation)" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def sleep_in(weekday, vacation):  if(weekday and not vacation):    return False  return True</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p174314.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be &#8220;case sensitive&#8221;). Note: s.lower() returns the lowercase version of a string.</p>
<p>end_other(&#8216;Hiabc&#8217;, &#8216;abc&#8217;) → True<br />end_other(&#8216;AbC&#8217;, &#8216;HiaBc&#8217;) → True<br />end_other(&#8216;abc&#8217;, &#8216;abXabc&#8217;) → True&#8230;Save, Compile, Run          <span id="hint"><button>Show Hint</button></span>
<pre style="border:2px solid gray;">def end_other(a, b):  a =a.lower()  b = b.lower()  if a[-len(b):] == b:    return True  if b[-len(a):] == a:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p177892.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an int array length 2, return True if it contains a 2 or a 3.</p>
<p>has23([2, 5]) → True<br />has23([4, 3]) → True<br />has23([4, 5]) → False&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def has23(nums):  a= nums  if a[0] == 2 or a[1] == 2 or a[0] == 3 or a[1] == 3:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p179078.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return True if the array is length 1 or more, and the first element and the last element are the same.</p>
<p>same_first_last([1, 2, 3]) → False<br />same_first_last([1, 2, 3, 1]) → True<br />same_first_last([1, 2, 1]) → True&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def same_first_last(nums):  if len(nums) &gt; 0 and (nums[0] == nums[len(nums)-1]):    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p179960.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">For this problem, we&#8217;ll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 rounds down to 10. Given 3 ints, a b c, return the sum of their rounded values. To avoid code repetition, write a separate helper &#8220;def round10(num):&#8221; and call it 3 times. Write the helper entirely below and at the same indent level as round_sum().</p>
<p>round_sum(16, 17, 18) → 60<br />round_sum(12, 13, 14) → 30<br />round_sum(6, 4, 4) → 10&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def round10(num):  if (num % 10) &gt;= 5:    return num +  10 - (num%10)  if (num % 10) &lt; 5:    return num -  (num%10)def round_sum(a, b, c):  return round10(a)+round10(b)+round10(c)</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p181624.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return True if 6 appears as either the first or last element in the array. The array will be length 1 or more.</p>
<p>first_last6([1, 2, 6]) → True<br />first_last6([6, 1, 2, 3]) → True<br />first_last6([3, 2, 1]) → False&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def first_last6(nums):  if nums[0] == 6 or nums[len(nums)-1]==6:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p182144.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given two strings, a and b, return the result of putting them together in the order abba, e.g. &#8220;Hi&#8221; and &#8220;Bye&#8221; returns &#8220;HiByeByeHi&#8221;.</p>
<p>make_abba(&#8216;Hi&#8217;, &#8216;Bye&#8217;) → &#8216;HiByeByeHi&#8217;<br />make_abba(&#8216;Yo&#8217;, &#8216;Alice&#8217;) → &#8216;YoAliceAliceYo&#8217;<br />make_abba(&#8216;x&#8217;, &#8216;y&#8217;) → &#8216;xyyx&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def make_abba(a, b):  return a + b + b + a</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p182414.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So &#8220;xxcaazz&#8221; and &#8220;xxbaaz&#8221; yields 3, since the &#8220;xx&#8221;, &#8220;aa&#8221;, and &#8220;az&#8221; substrings appear in the same place in both strings.</p>
<p>string_match(&#8216;xxcaazz&#8217;, &#8216;xxbaaz&#8217;) → 3<br />string_match(&#8216;abc&#8217;, &#8216;abc&#8217;) → 2<br />string_match(&#8216;abc&#8217;, &#8216;axc&#8217;) → 0&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def string_match(a, b):%0a  # Figure which string is shorter.%0a  shorter = min(len(a), len(b))%0a  count = 0%0a  %0a  # Loop i over every substring starting spot.%0a  # Use length-1 here, so can use char str[i+1] in the loop%0a  for i in range(shorter-1):%0a    a_sub = a[i:i+2]%0a    b_sub = b[i:i+2]%0a    if a_sub == b_sub:%0a      count = count + 1%0a%0a  return count" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def string_match(a, b):  loopcount = len(a)  if len(b) &lt; loopcount:    loopcount = len(b)  ret = 0  for i in range(loopcount-1):    if a[i:i+2] == b[i:i+2]:      ret+=1    return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p184816.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return the string made of its first two chars, so the String &#8220;Hello&#8221; yields &#8220;He&#8221;. If the string is shorter than length 2, return whatever there is, so &#8220;X&#8221; yields &#8220;X&#8221;, and the empty string &#8220;&#8221; yields the empty string &#8220;&#8221;. </p>
<p>first_two(&#8216;Hello&#8217;) → &#8216;He&#8217;<br />first_two(&#8216;abcdefg&#8217;) → &#8216;ab&#8217;<br />first_two(&#8216;ab&#8217;) → &#8216;ab&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def first_two(str):  if len(str) &gt; 2:    return str[0:2]  return str</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p184853.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values.</p>
<p>big_diff([10, 3, 5, 6]) → 7<br />big_diff([7, 2, 10, 9]) → 8<br />big_diff([2, 10, 7, 2]) → 8&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def big_diff(nums):  sortednum = sorted(nums)  return sortednum[-1] - sortednum[0]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p186048.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return the number of times that the string &#8220;code&#8221; appears anywhere in the given string, except we&#8217;ll accept any letter for the &#8216;d&#8217;, so &#8220;cope&#8221; and &#8220;cooe&#8221; count.</p>
<p>count_code(&#8216;aaacodebbb&#8217;) → 1<br />count_code(&#8216;codexxcode&#8217;) → 2<br />count_code(&#8216;cozexxcope&#8217;) → 2&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def count_code(str):  count = 0  for i in range(len(str)-3):    if str[i:i+2] =='co' and str[i+3:i+4] == 'e':      count+=1  return count</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p189441.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string, return a new string where &#8220;not &#8221; has been added to the front. However, if the string already begins with &#8220;not&#8221;, return the string unchanged. </p>
<p>not_string(&#8216;candy&#8217;) → &#8216;not candy&#8217;<br />not_string(&#8216;x&#8217;) → &#8216;not x&#8217;<br />not_string(&#8216;not bad&#8217;) → &#8216;not bad&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def not_string(str):%0a  if len(str) %26gt;= 3 and str[:3] == %26quot;not%26quot;:%0a    return str%0a  return %26quot;not %26quot; + str%0a  # str[:3] goes from the start of the string up to but not%0a  # including index 3" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def not_string(str):  ret = 'not '+str  if str[0:3] == 'not':    ret = str  return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p189616.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Return the number of even ints in the given array. Note: the % &#8220;mod&#8221; operator computes the remainder, e.g. 5 % 2 is 1.</p>
<p>count_evens([2, 1, 2, 3, 4]) → 3<br />count_evens([2, 2, 0]) → 3<br />count_evens([1, 3, 5]) → 0&#8230;Save, Compile, Run          <span id="hint"><button value>Show Hint</button></span>
<pre style="border:2px solid gray;">def count_evens(nums):  count = 0  for num in nums:    if num%2 ==0:      count+=1  return count</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p191645.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints length 3, return the sum of all the elements.</p>
<p>sum3([1, 2, 3]) → 6<br />sum3([5, 11, 2]) → 18<br />sum3([7, 0, 0]) → 7&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def sum3(nums):  return nums[0]+nums[1]+nums[2]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p192589.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return the sum of the first 2 elements in the array. If the array length is less than 2, just sum up the elements that exist, returning 0 if the array is length 0.</p>
<p>sum2([1, 2, 3]) → 3<br />sum2([1, 1]) → 2<br />sum2([1, 1, 1, 1]) → 2&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def sum2(nums):  if len(nums) == 0:    return 0      if len(nums) == 1:    return nums[0]  return nums[0]+nums[1]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p192962.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints length 3, return a new array with the elements in reverse order, so {1, 2, 3} becomes {3, 2, 1}.</p>
<p>reverse3([1, 2, 3]) → [3, 2, 1]<br />reverse3([5, 11, 9]) → [9, 11, 5]<br />reverse3([7, 0, 0]) → [0, 0, 7]&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def reverse3(nums):  nums.reverse()  return nums</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p193507.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given a string and a non-negative int n, return a larger string that is n copies of the original string.</p>
<p>string_times(&#8216;Hi&#8217;, 2) → &#8216;HiHi&#8217;<br />string_times(&#8216;Hi&#8217;, 3) → &#8216;HiHiHi&#8217;<br />string_times(&#8216;Hi&#8217;, 1) → &#8216;Hi&#8217;&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def string_times(str, n):%0a  result = %26quot;%26quot;%0a  for i in range(n):  # range(n) is [0, 1, 2, .... n-1]%0a    result = result + str  # could use += here%0a  return result" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def string_times(str, n):  ret = ''  for i in range(1,n+1):    ret = ret + str    return ret</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p193604.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an array of ints, return True if .. 1, 2, 3, .. appears in the array somewhere.</p>
<p>array123([1, 1, 2, 3, 1]) → True<br />array123([1, 1, 2, 4, 1]) → False<br />array123([1, 1, 2, 1, 2, 3]) → True&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def array123(nums):%0a  # Note: iterate with length-2, so can use i+1 and i+2 in the loop%0a  for i in range(len(nums)-2):%0a    if nums[i]==1 and nums[i+1]==2 and nums[i+2]==3:%0a      return True%0a  return False" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def array123(nums):  str = "".join(["%s" % el for el in nums])  if str.find('1') &gt;= 0 and str.find('2') &gt;= 0 and str.find('3') &gt;= 0:    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p194053.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0).</p>
<p>combo_string(&#8216;Hello&#8217;, &#8216;hi&#8217;) → &#8216;hiHellohi&#8217;<br />combo_string(&#8216;hi&#8217;, &#8216;Hello&#8217;) → &#8216;hiHellohi&#8217;<br />combo_string(&#8216;aaa&#8217;, &#8216;b&#8217;) → &#8216;baaab&#8217;&#8230;Save, Compile, Run
<pre style="border:2px solid gray;">def combo_string(a, b):  s = sorted([a,b],key=len)  return s[0]+s[1]+s[0]</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p195669.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return True if the party with the given values is successful, or False otherwise.</p>
<p>cigar_party(30, False) → False<br />cigar_party(50, False) → True<br />cigar_party(70, True) → True&#8230;Save, Compile, Run          <span id="hint">&lt;button onclick=&quot;document.getElementById(&quot;hint&quot;).innerHTML=unescape(&quot;Hint: One approach begins with%0a
<pre>%0aif is_weekend:%0a  ...%0aelse:%0a  ...%0a</pre>
<p>%0aIn each section, check cigars with %26gt;=, %26lt;= etc. to return True if cigars is in range or else return False. Extra trick: for shorter code, note that %26quot;return (x %26gt;= 50)%26quot; automatically returns True if x %26gt;= 50 and False if x %26lt; 50. This works because the expression %26quot;(x %26gt;= 50)%26quot; evaluates to the value True or False, and then that value is returned.&#8221;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Hint</button></span>
<pre style="border:2px solid gray;">def cigar_party(cigars, is_weekend):  if cigars &gt;=40 and (cigars &lt;=60 or is_weekend == True):    return True  return False</pre>
</td>
</tr>
</tbody>
</table>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<b>p197466.html</b> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; <br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.</p>
<p>diff21(19) → 2<br />diff21(10) → 11<br />diff21(21) → 0&#8230;Save, Compile, Run          &lt;button onclick=&quot;document.getElementById(&quot;results&quot;).innerHTML=&quot;<b>Solution:</b>
<pre>"+unescape("def diff21(n):%0a  if n %26lt;= 21:%0a    return 21 - n%0a  else:%0a    return (n - 21) * 2" + "</pre>
<p>&#8220;)&#8221; style=&#8221;visibility: hidden;&#8221;&gt;Show Solution</button>
<pre style="border:2px solid gray;">def diff21(n):  diff = abs(n - 21)  if n &gt; 21:    diff = diff * 2  return diff  </pre>
</td>
</tr>
</tbody>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=161&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding bat &#8211; solutions &#8211; Code</title>
		<link>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-code/</link>
		<comments>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-code/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 04:59:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[URLLIB]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-code</guid>
		<description><![CDATA[Now that the solutions are downloaded, i dont know how to attach them as a file link here, so i need to extract all the QUESTION &#8211; ANSWER part and post it &#8230;.there goes the parsing again&#8230;.. this is the program that i used to parse the output and save the contents&#8230;import sysimport reimport os [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=162&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that the solutions are downloaded, i dont know how to attach them as a file link here, so i need to extract all the QUESTION &#8211; ANSWER part and post it &#8230;.there goes the parsing again&#8230;..</p>
<p>this is the program that i used to parse the output and save the contents&#8230;<br />import sys<br />import re<br />import os</p>
<p>directory = &#8216;d:\\scripts\\myhack\\&#8217;<br />filelist = os.listdir(directory)</p>
<p>f = open(r&#8217;d:\full.html&#8217;,'w&#8217;)<br />for filename in filelist:<br />    print filename<br />    file = open(os.path.join(directory,filename),&#8217;r')<br />    content = file.read()<br />    sindex = content.find(&#8216;<br />
<table border="0">
<tbody>
<tr>
<td valign="top" width="700">&#8216;)<br />    endIndex = content.find(&#8221;)<br />    newcon = content[sindex:endIndex+11].replace(&#8216;textarea&#8217;,'pre&#8217;).replace(&#8216;button&#8217;,'button style=\&#8221;visibility:hidden\&#8221;&#8216;)+&#8217;</td>
</tr>
</tbody>
</table>
<p>&#8216;<br />    f.write(&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8217;)<br />    f.write(&#8216;<b>&#8216;+filename+&#8217;</b>&#8216;)<br />    f.write(&#8216;\n&#8217;)<br />    f.write(&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8217;)<br />    f.write(&#8216;\n&#8217;)<br />    f.write(newcon)<br />    f.write(&#8216;\n&#8217;)<br />f.close()</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=162&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/11/25/coding-bat-solutions-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Parse Hyperlinks &#8211; Python</title>
		<link>http://consoleart.wordpress.com/2010/11/25/parse-hyperlinks-python/</link>
		<comments>http://consoleart.wordpress.com/2010/11/25/parse-hyperlinks-python/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 04:53:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Parsing hyperlinks]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[URLLIB]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/11/25/parse-hyperlinks-python</guid>
		<description><![CDATA[ While doing my previous post (downloading content from codingbat) i got this script for parsing the url links urls = re.findall(r&#8217;href=[\'"]p?([^\'" &#62;]+)&#8217;, line) r &#8211; is provided to denote the string is a rawstring(we dont need to specify escape charcters)href=[\'"] &#8211; the string must start with &#8220;HREF=&#8221; and can either have any of the characters [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=163&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> While doing my previous post (downloading content from codingbat) i got this script for parsing the url links <a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name=""></a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name=""><br /></a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name=""> urls = re.findall(r&#8217;href=[\'"]p?([^\'" &gt;]+)&#8217;, line)</a></p>
<p><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name="">r &#8211; is provided to denote the string is a rawstring(we dont need to specify escape charcters)</a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name="">href=[\'"] &#8211; the string must start with &#8220;HREF=&#8221; and can either have any of the characters (&#8216; &#8211; single quote, &#8221; &#8211; double quote) next to it.</a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name="">p? &#8211; the next character must be a p</a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name="">([^\'" &gt;]+) &#8211; it must end with a greater than symbol which must be preceeded either by single or double quote.</a><br /><a href="http://www.blogger.com/post-create.g?blogID=1986533493435876207" name=""><br /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=163&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/11/25/parse-hyperlinks-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding bat &#8211; Post Soutions</title>
		<link>http://consoleart.wordpress.com/2010/11/24/coding-bat-post-soutions/</link>
		<comments>http://consoleart.wordpress.com/2010/11/24/coding-bat-post-soutions/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 12:11:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[URLLIB]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/11/24/coding-bat-post-soutions</guid>
		<description><![CDATA[I am not sure whether this is a intellectual property right, but these are the exercises that I solved in coding bat, a site by Nick Parlante ( who was a inspiration for me to seriously look at Python ) ok I have been trying for an hour to hack into coding bat with my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=164&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am not sure whether this is a intellectual property right, but these are the exercises that I solved in coding bat, a site by Nick Parlante ( who was a inspiration for me to seriously look at Python )</p>
<p>ok I have been trying for an hour to hack into coding bat with my user name and password &#8211; using python urllib2 module, there seems to something that keeps me out of their pages.</p>
<p>I am just trying to download their tutorials and post it in my blog (the actual reason for creating this particular blog post), so i have downloaded this python module called mechanize which is very promising, have to try it out and see whether it works&#8230;</p>
<p>[EDIT:]<br />and it works !!! this is the download link for the web site</p>
<p>http://wwwsearch.sourceforge.net/mechanize/<br />and here is the coding that I used to get access to the web site and download the content</p>
<p>#/usr/bin/env python<br />import sys, os, re<br />from urllib2 import HTTPError</p>
<p>import mechanize<br />assert mechanize.__version__ &gt;= (0, 0, 6, &#8220;a&#8221;)<br />mech = mechanize.Browser()<br />mech.set_handle_robots(False)</p>
<p>try:<br />    mech.open(&#8220;http://codingbat.com&#8221;)<br />except HTTPError, e:<br />    sys.exit(&#8220;%d: %s&#8221; % (e.code, e.msg))</p>
<p>mech.select_form(nr=0)<br />mech["uname"] = &#8220;your registered email id&#8221;<br />mech["pw"] =  &#8220;password&#8221;<br />mech.submit()</p>
<p>#s = mech.retrieve(&#8216;http://codingbat.com&#8217;,'d:/aa.html&#8217;)<br />#[EDIT] <br />#this page will throw up error stating the user or tag is expired, what you need to do is login to the web site and copy the link for the &#8220;DONE&#8221; page here<br />mech.retrieve(&#8216;http://codingbat.com/done&#8217;,'d:/url.html&#8217;)</p>
<p>content = open(&#8216;d://url.html&#8217;,'r&#8217;).readlines()<br />i=0<br />for line in content:<br />    urls = re.findall(r&#8217;href=[\'"]p?([^\'" &gt;]+)&#8217;, line)<br />    for url in urls:<br />            if url[0:4] == &#8216;/pro&#8217;:<br />                i+=1<br />                print &#8220;Processing&#8221;,&#8217;http:/codingbat.com&#8217;+url<br />                mech.retrieve(r&#8217;http://codingbat.com&#8217;+url,&#8217;d://myhack//&#8217;+str(i)+&#8217;.html&#8217;)</p>
<p>#make sure you create a folder d:\myHack which will used to save the files.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=164&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/11/24/coding-bat-post-soutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
		<item>
		<title>Database access &#8211; GUYI &#8211; Part I &#8211; Server Auth Page</title>
		<link>http://consoleart.wordpress.com/2010/11/24/database-access-guyi-part-i-server-auth-page/</link>
		<comments>http://consoleart.wordpress.com/2010/11/24/database-access-guyi-part-i-server-auth-page/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 10:17:00 +0000</pubDate>
		<dc:creator>consoleart</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[URLLIB]]></category>

		<guid isPermaLink="false">http://consoleart.wordpress.com/2010/11/24/database-access-guyi-part-i-server-auth-page</guid>
		<description><![CDATA[3:43So, we have two class that can be used to connect to the database and retrieve records based on a query (see my previous two posts). Now let us start forming the basics of the GUI, a page/screen which will be used to get &#38; store the connection string settings, option to load the saved [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=165&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><i>3:43</i>So, we have two class that can be used to connect to the database and retrieve records based on a query (see my previous two posts).</p>
<p>Now let us start forming the basics of the GUI, a page/screen which will be used to get &amp; store the connection string settings, option to load the saved connection string settings.</p>
<p>Following will be a summary of the functionality which needs to be done.<br />-&gt; Select existing connection strings<br />-&gt;select database type (MY SQL/MS SQL/ORACLE)<br />-&gt;IP address/severname<br />-&gt; database name<br />-&gt; user name and password</p>
<p>After getting these details validate the connection setting and save them in a FLAT file.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/consoleart.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/consoleart.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/consoleart.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=consoleart.wordpress.com&amp;blog=3015197&amp;post=165&amp;subd=consoleart&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://consoleart.wordpress.com/2010/11/24/database-access-guyi-part-i-server-auth-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5b32cdc3d13dff9494ad944f27c2ea10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">consoleart</media:title>
		</media:content>
	</item>
	</channel>
</rss>
