Solved-Lab 01- Solution

$30.00 $19.00

Based on hour study of programs lets_mingle.py, send.py, and catch_me.py, answer the following questions or perform the following tasks in the Python programming language. For some of the question, you may decide to consult online or other sources on Python. Write a line of code that assigns value 55 to a variable. Write the code…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

Based on hour study of programs lets_mingle.py, send.py, and catch_me.py, answer the following questions or perform the following tasks in the Python programming language. For some of the question, you may decide to consult online or other sources on Python.

  1. Write a line of code that assigns value 55 to a variable.

  1. Write the code that prints out all numbers from 1 to 20.

  1. Write the code that prints out all even numbers between 1 20.

  1. Write the code that prints out ten random integers between 1 and 100.

  1. What is the difference between the following two ways of importing modules?

import some_module

and

from some_module import *

6. What is the difference between the following two Python instructions:

print “hello”

and

print “hello”,

  1. In the declared graphics window object in catch_me.py with win = GraphWin(“Catch Me!!”, 500, 500)

where are the coordinates (0,0) located? (upper left corner, lower left corner, upper right corner, lower right corner).

8. What is the difference (if there is any) between the following two blocks of code?

if x % 2 == 0:

print “even ”,

print “number”

and

if x % 2 == 0:

print “even “,

print “number”

  1. What is the code to define a class Book with data members for the book title, year of publication and number of pages? What is the instruction that will make variable mybook be assigned the value of a specific Book objects (your choice)?

  1. What is the purpose of the line

if __name__ == ‘__main__’:

in a Python program. The program in catch_me.py features this line, but the program in lets_mingle.py does not include it. What is going on?