Question

In: Computer Science

I need the ex1 and ex2 files written out. The book is "in a byte of...

I need the ex1 and ex2 files written out. The book is "in a byte of python" basics chapter. I can copy and paste WORKING CODE into an editor. Thank you!

1.     In A Byte of Python

       - read and test Basics chapter in python intrepreter



2.     create a source file; run a program in Terminal

       - copy "Example: Using Variables And Literal Constants" from Basics chapter

       - attach identifying comment (in all your future programs)

       - save the file as ex1.py in your ITP/asn3 folder

       - test, fix errors, repeat until working



3.     create your own original source code file

       - demonstrate several other features in the Basics chapter
       
       - save the file as ex2.py in your ITP/asn3 folder



3.     for our next class

       - read "Operators and Expressions" from "A Byte of Python"



4.     10 Points

       5     ex1.py in your ITP/asn3 folder
       5     ex2.py in your ITP/asn3 folder

Solutions

Expert Solution

// For any doubt, feel free to comment.

// I am providing both codes and screenshots

ex1.py

#adding identifying comments for future use

#Copying code from "Example: Using Variables And Literal Constants"

#below code running without errors
i = 5
print i

i = i + 1
print i

s = '''This is a multi-line string.
This is the second line.'''
print s


ex2.py

# 5.1 - Comments
#adding identifying comments for future use
''' Adding multi-lines
comments'''
  
#adding single line comments

# 5.2 - Literal Constants
s = 'This is a literal constant'
print s

# 5.3 - Numbers
n = 100 #Numbers
print n

# 5.4 - Strings
s1 = 'String in single quotes'
s2 = "String in double quotes"
s3 = '''String in triple quotes'''
print s1
print s2
print s3

# 5.5 - Variable
v = 'I am a variable = 100'
print '{0} printing with format '.format(v)

# 5.4.6 - Escape Sequences
s4 = 'This is the first line\nThis is the second line'
print s4


Related Solutions

Files I need to be edited: I wrote these files and I put them in a...
Files I need to be edited: I wrote these files and I put them in a folder labeled Project 7. I am using this as a study tool for a personal project of mine. //main.cpp #include <iostream> #include "staticarray.h" using namespace std; int main( ) {    StaticArray a;    cout << "Printing empty array -- next line should be blank\n";    a.print();    /*    // Loop to append 100 through 110 to a and check return value    // Should print "Couldn't append 110"...
-please answer this written out. Do not use excel I cannot access it. i need to...
-please answer this written out. Do not use excel I cannot access it. i need to know how to do it on paper- Deluxe River Cruises operates a fleet of river vessels. The fleet has two types of vessels: A type A vessel has 60 deluxe cabins and 160 standard cabins, whereas a type B vessel has 80 deluxe cabins and 120 standard cabins. Under a charter agreement with the Odyssey Travel Agency, Deluxe River Cruise sis to provide Odyssey...
***You can use a calculator but I just need the work written out so I can...
***You can use a calculator but I just need the work written out so I can see what you did and how you did it*** I need the answer for number 4 which is based on number 3. Please answer number 4 based on number 3. Number 4 can be found at the bottom. Thank you! 3. A business takes out a loan for $250,000 at 4.8% interest compounded monthly. If the business can afford to make monthly payments of...
EX1 EX2 Ex3 FINAL 73 80 75 152 93 88 93 185 89 91 90 180...
EX1 EX2 Ex3 FINAL 73 80 75 152 93 88 93 185 89 91 90 180 96 98 100 196 73 66 70 142 53 46 55 101 69 74 77 149 47 56 60 115 87 79 90 175 79 70 88 164 69 70 73 141 70 65 74 141 93 95 91 184 79 80 73 152 70 73 78 148 93 89 96 192 78 75 68 147 81 90 93 183 88 92 86 177...
i don't need a google answer please! i need it from any nutrition book What are...
i don't need a google answer please! i need it from any nutrition book What are necessary energy and nutrient requirements essential for normal growth and development during infancy, childhood and adolescence?
i need an example of a program that uses muliple .h and .cpp files in c++...
i need an example of a program that uses muliple .h and .cpp files in c++ if possible.
I need this in java on textpad. There are two files, both have instructions in them...
I need this in java on textpad. There are two files, both have instructions in them on what to add in the code. They are posted below. public class MyArrayForDouble { double[] nums; int numElements; public MyArrayForDouble() { // Constructor. automatically called when creating an instance numElements = 0; nums = new double[5]; } public MyArrayForDouble(int capacity) { // Constructor. automatically called when creating an instance numElements = 0; nums = new double[capacity]; } public MyArrayForDouble(double[] nums1) { nums =...
I need a randomized quicksort function written in c++ or java with dual pivots and a...
I need a randomized quicksort function written in c++ or java with dual pivots and a partition function
I need a written contract that can be breached. It can be any kind of made...
I need a written contract that can be breached. It can be any kind of made up contract. Module 02 Course Project - The Contract: (This project is a compilation of skills required to understand Internet Law in its many facets. The students will demonstrate their knowledge of the Internet, laws associated with the internet, cases associated with the laws of the internet, possible remedies or sanctions given a break in the law and the ability to be self-reliant in...
I need code written in java for one of my projects the instructions are Write a...
I need code written in java for one of my projects the instructions are Write a program that interacts with the user via the console and lets them choose options from a food menu by using the associated item number. It is expected that your program builds an <orderString> representing the food order to be displayed at the end. (See Sample Run Below). Please note: Each student is required to develop their own custom menus, with unique food categories, items...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT