What is the resulting data type

Assignment Help Python Programming
Reference no: EM133091466

Introduction to Python, Operators and Data Types

Exercise 1:  There are three main ways in which high-level source code can be converted into machine code suitable for running on a processor - Compilation, Pure Interpretation and Hybrid Implementation. In your own words, describe each of these different techniques and also rank them from fastest to slowest.

Exercise 2. Which of the above techniques does Python 3 use? Why do you think this might be? Do a spot of research if you're not sure!

Exercise 3. Give at least two examples of each of the following types of data:

Data Type

Example 1

Example 2

Integer

 

 

Boolean

 

 

Float

 

 

Double

 

 

String

 

 

Exercise 4. Provide the operator symbol for each of the following operators:

Operation

Symbol

Addition

 

Subtraction

 

Multiplication

 

Division (floating point)

 

Division (integer)

 

Modulus

 

Raise to a power

 

Equivalence

 

Not equal to

 

Assignment

 

Exercise 5. What is the resulting data type when we combine the following data types in the following ways.Try them out in the Python interpreter if you're not sure (some of them might surprise you), like this for example:
i = int(3)
f = float(4.0)
s = "five"
b = True
i_times_f = i * f
print(type(i_times_f), i_times_f) # float

First data type

Operation

Second data type

Resulting data type

Integer

Multiplied by

Float

Float

Integer

Multiplied by

Integer

 

Integer

Divided by

Integer

 

Integer

Integer-divided by

Integer

 

Float

Integer-divided by

Integer

 

String

Multiplied by

Integer

 

Integer

Multiplied by

String

 

Float

Divided by

Float

 

Float

Integer-divided by

Float

 

String

Added to

String

 

String

Subtracted from

String

 

Exercise 6. What data type is returned when we use Python 3's input function? Assuming the user entered a whole number, give an example of casting this data type into an integer.

Exercise 7. Write a small Python 3 script that asks the user to enter their birthday as three separate values (day, monthand year) and then prints out how old they are in the following format (for example):
If you were born on 18/01/1978 then that was day 18 of the year.
Use the format function to substitute values into your output. You can use the following snippet of code to calculate the day of the year:
import datetime as dt
date = dt.date(birth_year, birth_month, birth_day) # Create a date from user data
day_of_year = date.timetuple().tm_yday # Get day number from date
This code assumes that when you got the user's birthday details you stored them in variables called birth_day, birth_month and birth_year - if you didn't then either do so or substitute your own variable names into the date line (i.e. the middle line) above!

Exercise 8. Challenge Task - try this if you're feeling adventurous! You won't get any help with it, it's just to ‘stretch' you a little bit if you're finding all this too easy!
Write a program that outputs the lyrics to the classic love-song 99 Bottles of Beer On The Wall - using a loop!

The song's lyrics are as follows:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down, pass it around, 98 bottles of beer on the wall...
The same verse is repeated, each time with one bottle fewer, until there are none left. On the very last verse when there are zero bottles left, the lyrics change to:
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall...
Whatever you do, don't type the lot in - it's a waste of your time and energy! Instead, use a loop (take a look at the range statement
You can cheat for the last verse if you like by putting it after the loop, or... you could use an if / else comparison if you go look ‘em up.
If you wanted the song to last a bit longer than the split-second it'll take for Python to output the entire lyrics, then put the following as the first line of your program:
import time
Then, somewhere in your loop add the following line so that it waits half a second between each iteration:
time.sleep(0.5)

It's quite possible to complete this entire task including the sleep-delay in less than 10 lines of code- so make Jay-Z proud!

Reference no: EM133091466

Questions Cloud

Social media impacted maslow hierarchy : How has Social Media impacted Maslow's (secondary) Hierarchy of needs? How has the hierarchy evolved post COVID-19 pandemic?
Explain the sources of power : Identify and explain the significance the following term (or phrase): Sources of power
How much basic federal tax will he save : Raymond, who is single, is enrolled in part-time studies. His net and taxable income is $49,500. How much basic federal tax will he save
What is csr benchmarking : Many companies use the strategy of benchmarking to compete within their respective industries in CSR policy, implementation, and effectiveness.
What is the resulting data type : What is the resulting data type when we combine the following data types in the following ways.Try them out in the Python interpreter if you're not sure
Outline hersey and blanchard situational leadership model : The Director of Human Resources of Baptist Health System, an integrated network of non-profit hospitals, physician clinics, and home medical services with over
Basic product in introductory stage of lifecycle : Describe the basic product in the introductory stage of the lifecycle. how would you now describe the product?
What is the contribution margin per the constrained resource : What is the contribution margin per the constrained resource for table saw blades
Means of expressing management : Critical writers suggest that leadership is simply a means of expressing management in a way that employees would find more acceptable and therefore work harder

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd